nnnn
nnnn

Reputation: 1051

Stop Moving to next control on Tab Key

I have a numbers of Controls on my form, set with tabindexs and tabstop set to true.

eg. I have 3 Text Box.

Name     TabIndex
TextBox1  0 
TextBox2  1
TextBox3  3

When I press Tab Key, the cursor move to next control.
When I press Tab Key in last control(TextBox3),the cursor move to first control.

eg.
TextBox1 -> TextBox2 -> TextBox3 -> TextBox1 -> TextBox2 -> TextBox3..

The Solution I want is
"When I press Tab Key in last control(TextBox3),I don't want to move the cursor to first control.I want to remain the cursor on last control (TextBox3)."

eg. TextBox1 -> TextBox2 -> TextBox3(Stop Moving Cursor)

Can anybody give me a solution for this? Thanks in advance.

Upvotes: 1

Views: 2729

Answers (1)

VB.NET LEARNER
VB.NET LEARNER

Reputation: 711

Hi this piece of coding can help you

On the GotFocus Event of Textbox2 set the other two textbox tabstop to false

 Private Sub TextBox2_GotFocus(ByVal sender As Object, ByVal e As
 System.EventArgs) Handles TextBox2.GotFocus
        If TextBox3.TabStop = True Then
            TextBox1.TabStop = False
            TextBox2.TabStop = False
        End If
    End Sub

Upvotes: 0

Related Questions