Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cursor Position Inside a Text Box

Status
Not open for further replies.

PaulBarbeau

Programmer
Nov 23, 2000
109
CA
I am look to see if

1) can find out where the cursor is inside a text box and/or edit box eliment on a form.
2) if when i set the focus i can move to the end of the the eliment or a spot inside the field.


i know if the user select text i can found that out however if they do not how do i?

Thanks for your help

Paul
 
Hi
If you want to position at the end or at some place of an edit box or text box.. look in this thread
text in a edit control
thread184-598843

In fact that is a reminder and that is your thread !!!

ramani :)
(Subramanian.G)
 
Yes however that is if i select the text. i do not want to do that i want to know where the cursor is when i do not select the text. It is a different question.

Paul
 
Hi Paul,
DO it with SelStart. That will position the cursor at the place you want.

If you want to go the end of the text in a text box..
In its GotFocus Event..
KEYBOARD '{END}'


:)

ramani :)
(Subramanian.G)
 
i tried SelStart before i did my post and return me a 0 i will try it again. thanks for the help and the for {end}. did not think of that thanks.

Paul
 
Paul,

If the insertion point is present (that is, no text is highlighted), then SelStart should give you the position. You can programmatically set SelStart to the length of the text; that will move the cursor to the right-hand end. However, keep in mind that if the text is wider than the text box, this will cause it to scroll horizontally to the right, which might not be what you want.

Mike


Mike Lewis
Edinburgh, Scotland
 
Thanks it works for me now i had to change the position of when i store the value to the lostfocus(). I was checking in the click of the button back to the elimited and it was "0" then.

Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top