I have a WinForms application with a richTextBox. I would like to be able to cut, copy and paste formatted text in my application. Currently, my code consists of:
Cut all:
richTextBoxPrintCtrl1.Cut();
Cut Selected:
Clipboard.SetText(richTextBoxPrintCtrl1.Text);
richTextBoxPrintCtrl1.Text = "";
Copy all:
richTextBoxPrintCtrl1.Copy();
Copy Selected:
Clipboard.SetDataObject(richTextBoxPrintCtrl1.SelectedText);
Paste:
DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Text);
richTextBoxPrintCtrl1.Paste(myFormat);
I would like it so that if I cut/copy text from the richTextBox, it keeps ALL formatting (size, font, colour etc.), and if I paste text to the richTextBox, it also keeps all formatting.
How would this be achieved?
Thanks.