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.SelectionFont = font;

//Copy updated text back to the clipboard

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: Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: