C# copy function richtextbox with formatting [clos

2019-09-21 19:41发布

How do I make a button that allows me to copy like the ctrl+c function. I want to select a part of a rich text box and when the button is clicked it copies the selected part. With formatting!

1条回答
Fickle 薄情
2楼-- · 2019-09-21 20:03

On button click event you should do something like:

if (richTextBox1.SelectionLength > 0)
// Copy the selected text to the Clipboard
Clipboard.SetText(richTextBox1.SelectedText, TextDataFormat.Text);
查看更多
登录 后发表回答