Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


TextBox cursor position


TextBox cursor position

Author
Message
pirahnaplant
pirahnaplant
Forum God
Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)

Group: Forum Members
Posts: 10, Visits: 122
How can I change the position that the cursor is at in VB 2008
waynespangler
waynespangler
Forum God
Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)

Group: Forum Members
Posts: 910, Visits: 5.4K
Give an example of what you are looking for. The cursor is moved around with the mouse. The position of the cursor in a textbox, listbox, etc.?

Wayne

I know enough to be dangerious.

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.

pirahnaplant
pirahnaplant
Forum God
Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)Forum God (2K reputation)

Group: Forum Members
Posts: 10, Visits: 122
I meant how can I change where the cursors position is in a textbox from within the code.  I was wondering, because whenever you change the text box text like TextBoxName.Text = "somthing" the cursor is put back at the beginning if you do this with the text box text changed event.  I want to be able to put the cursor back at the end when this happens.
waynespangler
waynespangler
Forum God
Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)

Group: Forum Members
Posts: 910, Visits: 5.4K
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim hold As Integer = TextBox1.SelectionStart
        TextBox1.Text = "something"
        TextBox1.SelectionStart = hold
        TextBox1.Focus()
    End Sub


Wayne

I know enough to be dangerious.

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.

waynespangler
waynespangler
Forum God
Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)

Group: Forum Members
Posts: 910, Visits: 5.4K
I'm sorry you wanted to place the cursor at the end of the new text. Try this:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = "something"
        TextBox1.SelectionStart = TextBox1.TextLength
        TextBox1.Focus()
    End Sub



Wayne

I know enough to be dangerious.

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.

_KaboOm_
_KaboOm_
Forum God
Forum God (327 reputation)Forum God (327 reputation)Forum God (327 reputation)Forum God (327 reputation)Forum God (327 reputation)Forum God (327 reputation)Forum God (327 reputation)Forum God (327 reputation)Forum God (327 reputation)

Group: Forum Members
Posts: 1, Visits: 1
If you want to put the cursor of a text box in the end, you just need one line:



If your textbox are not focus:



...code...

myTextBox.Focus()

SendKeys.Send("{End}")

...code...



If your textbox are focus:



...code...

SendKeys.Send("{End}")

...code...

How2Prog
How2Prog
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12
Hi,



If you mean that change the focused textbox, it's very easy, you should only go to the view menu and select change tab order, or by selecting the control and go to its properties and change the value of TabIndex.

Or go to form_load event and tape this:





TextBox1.Focus()





======================

http://www.how2prog.com



How2Prog.Com Is a wonderful space to learn programming easily, includes many of the open source projects in many different programming languages (Visual Basic.Net, C#.Net, Java EE, ...)
Edited
3/26/2013 by How2Prog
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search