最佳解答者
How to get a highlighted text into the clipboard?

問題
解答
-
If you want to select a part of the text in a TextBox control, you can make use of these porperties:
textBox1.SelectionStart
textBox1.SelectionLength
textBox1.SelectedText
If you find that your text is not highlighted, it might be your textbox is not in focus. Try this:
textBox1.Focus();
I am not clear what Jacky is refering to but I find this is working even on TextBox. Tested with VS 2005 C#.
FYI: http://msdn.microsoft.com/en-us/library/hk09zy8f.aspx2008年5月21日 上午 03:17 -
Hi Jack,
You are correct... SelectedText, SelectionStart and SelectionLength is Inherited from TextBoxBase, just get lost...
And Martin, I think the example is exact what you are looking for:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectedtext.aspx
2008年5月21日 上午 11:49
所有回覆
-
If you want to select a part of the text in a TextBox control, you can make use of these porperties:
textBox1.SelectionStart
textBox1.SelectionLength
textBox1.SelectedText
If you find that your text is not highlighted, it might be your textbox is not in focus. Try this:
textBox1.Focus();
I am not clear what Jacky is refering to but I find this is working even on TextBox. Tested with VS 2005 C#.
FYI: http://msdn.microsoft.com/en-us/library/hk09zy8f.aspx2008年5月21日 上午 03:17 -
Hi Jack,
You are correct... SelectedText, SelectionStart and SelectionLength is Inherited from TextBoxBase, just get lost...
And Martin, I think the example is exact what you are looking for:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectedtext.aspx
2008年5月21日 上午 11:49