I need to create and copy some RichText to the clipboard with standard "formatting", for example, bold / italics, indentation, etc. The way I am doing this now seems a bit inelegant ... I create a RichTextBox element and apply my formatting as follows:
RichTextBox rtb = new RichTextBox();
Font boldfont = new Font("Times New Roman", 10, FontStyle.Bold);
rtb.Text = "sometext";
rtb.SelectAll()
rtb.SelectionFont = boldfont;
rtb.SelectionIndent = 12;
There should be a better way, but after several hours of searching, I could not come up with anything better. Any ideas?
Edit: RichTextBox (rtb) is not displayed / drawn anywhere on the form. I just use an object to format a RichText.
source
share