highlighting in textbox control w/o mouse pointer

  • Thread starter Thread starter VMI
  • Start date Start date
V

VMI

I have two textbox controls and I want my application to automatically
highlight in the second textbox control the same amount of chars (and the
same position) that are being highlighted in the first textbox.
For example, if textbox1 has string "File is open" and textbox2 has "File is
closed", and I highlight 'open' in textbox1, textbox2 should automatically
highlight "close".

Is this possible?
Thanks.
 
I assume you're developing a windows application.
The task that you want can be achieved as follows:

(1) Set the HideSelection property to false for both the textboxes in form's
constructor
this.textBox1.HideSelection = false;
this.textBox2.HideSelection = false;

(2) Write the following two lines in textBox1_MouseUp() and
textBox2_KeyUp() events:
textBox2.Select(textBox1.SelectionStart,textBox1.SelectionLength);
textBox2.Refresh();

So selection of textbox2 changes as per selection of textbox1.
Hope this helps.
 
Back
Top