xyzio

Change Font Type in Clipboard with C#

leave a comment »

Convert text in the Clipboard to another font and re-save it to the clipboard in C#.


RichTextBox rtb = new RichTextBox();

//The new font is GenericMonospace
Font font = new Font(FontFamily.GenericMonospace, 10);

//Get text from the clipboard
rtb.Text = Clipboard.GetText();

//Select all text in the RichTextBox and apply fontstyle
rtb.SelectAll();
rtb.SelectionFont = font;

//Copy updated text back to the clipboard
rtb.Copy();

Written by M Kapoor

December 23, 2019 at 9:39 pm

Posted in Programming

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: