Position of Cursor in Textbox

  • Thread starter Thread starter Gene Hubert
  • Start date Start date
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
 
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
 
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.
--------------------
 
Back
Top