Click here to Skip to main content
16,018,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a text box called txtgoto.
If I enter any number in txtgoto and click button btnGoToLine the cursor should goto the required
line in the textbox txtMain and blink in the beginning of that line.

Ca anyone get me a code for this problem
Posted
Comments
Chandra Mohan N 26-Feb-14 5:15am    
Use java script,use focus() method.

1 solution

If this is winforms, then you need to use the Select method:
C#
int pos = myTextBox.GetFirstCharIndexFromLine(7);
if (pos >= 0) 
   {
   myTextBox.Select(pos, 0);
   }
Would set it to the start of line seven
 
Share this answer
 
Comments
KUMAR619 26-Feb-14 5:58am    
@OriginalGriff
Thanks
Your code works fine
OriginalGriff 26-Feb-14 6:06am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900