Position of Cursor in Textbox

G

Gene Hubert

For a string that is being edited in a textbox, is there a way to find
the position of the edit cursor in the string being edited? For
example, it would be 0 or 1 at the beginning of a string and go up by
one each time the right arrow key was pressed.

Thanks Much,
Gene in NC
 
K

Kirk

The SelectionStart property of the textbox should give you the position of
the cursor. You should also check the SelectionLength property as this will
tell you if the use has selected an area of the text and not just placed the
cursor in the textbox.

Kirk

TextBox1.SelectionStart
 
J

Josh Moody [MSFT]

Hey Gene -

This little snippit should help:

Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
Debug.WriteLine(TextBox1.SelectionStart())
End Sub


Josh Moody
VSU Team

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top