RichTextBox select text... Need top level select, not internal slc

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello and thank you for reading this post.

I have a RichTextBox. I need to select text inside for a search feature.
Easy enough... right? Well apparently from the .NET help and everything from
the net, there is nothing describing how to do a top level select that I can
find (ie like how to select or highlight programitcally like a user
highlights text from any window).

Here is my code:

//////////////////////////////////////////
resultPrint.Text = "Found";

WordList_box.SelectionBackColor = Color.Red;

WordList_box.SelectionStart = foundIndex;
WordList_box.SelectionLength = CSWordList_findBox.Text.Length;
//////////////////////////////////////////////

Thats fine, but the user cannot hit CTRL+C and copy that selection. I have
tried many variations but cannot figure out the right way.

Any ideas?

Thank you all,

Rob K
 
Thats fine, but the user cannot hit CTRL+C and copy that selection. I have
tried many variations but cannot figure out the right way.

The RichTextBox class doesn't implement a user interface - that's up to you.
In your program, you can detect CTRL+C, and call the RichTextBox routine to
copy any selected text to the clipboard. RichTextBox also has routines for
paste, cut, undo, redo, and other things that you can connect to your UI as
appropriate.

Brian.
 
Ahh... that makes sense... that would explain why you can select the text,
but never physically see the highlighting unless you customize the colors
manually. I will be monitoring keyboard strokes anyways, so CTRL C shouldn't
be too bad. Thank you for replying Brian!

Rob K
 
Back
Top