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 comment