复制自RichTextBox中选定的文本 [英] Copy selected text from RichTextBox

查看:167
本文介绍了复制自RichTextBox中选定的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有搜索周围的网,但我无法找到复制/剪切/粘贴从的RichTextBox 所选文本的方法。

I have searched around on the net but I cannot find a method of copying/cutting/pasting selected text from a RichTextBox.

即使MSDN没有答案。他们提供的代码不起作用:复制()只出现在文本框,而不是RichTextBoxes工作

Even MSDN does not have an answer. The code they provide does not work: Copy() only appears to work on TextBoxes, not RichTextBoxes.

推荐答案

如果您正在使用.NET 3.0及以上版本,你可以随时使用的 Clipboard.SetText()

If you're using .NET 3.0 and above you can always use Clipboard.SetText()

我发现它有用使用剪贴板时,我想的一切RichTextBox的,而不必选择家居第一或当我需要改变字符串:

I found it useful to use the Clipboard when I want everything in the richTextBox without having to select everything first or when I need to change the string:

string text = "Summary:" + Environment.NewLine + this.richTextBoxSummary.Text;
Clipboard.SetText(text);

这篇关于复制自RichTextBox中选定的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆