[RESOLVED] Is there a way to stop a tab switch?
Hello,
In my form I have a set of tabs and within a couple of them I have text boxes for input. I've settled on a validation of the input in the box that checks based on the "Leave" function when the user clicks off the box. It's easy to select the box again after the message box using a mybox.select() and to restore the deaulft input and let the user correct it as long as the user isn't clicking on another tab. If he does though - the form switches to the new tab after restoring the default but before the box can be corrected by the user and he has to switch back manually. I tried including a mytab.select() statement in the ""Leave" function, but it's not working.
I'd like to prevent the switching of the tabs if possible. Does anyone have any suggestions please?
Here's an example of my validation code for integers. The first function I found at http://www.kdkeys.net/forums/836/ShowPost.aspx. The second function I figured out:
I looked for something similar to the "Handled" function that's present for keypressed as above in the tabs class but couldn't find anything.
Thank you very much.
Hello,
In my form I have a set of tabs and within a couple of them I have text boxes for input. I've settled on a validation of the input in the box that checks based on the "Leave" function when the user clicks off the box. It's easy to select the box again after the message box using a mybox.select() and to restore the deaulft input and let the user correct it as long as the user isn't clicking on another tab. If he does though - the form switches to the new tab after restoring the default but before the box can be corrected by the user and he has to switch back manually. I tried including a mytab.select() statement in the ""Leave" function, but it's not working.
I'd like to prevent the switching of the tabs if possible. Does anyone have any suggestions please?
Here's an example of my validation code for integers. The first function I found at http://www.kdkeys.net/forums/836/ShowPost.aspx. The second function I figured out:
VB.NET:
Private Sub MyBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBox.KeyPress
If Char.IsDigit(e.KeyChar) = False And Char.IsControl(e.KeyChar) = False Then
e.Handled = True
End If
End Sub
Private Sub MyBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBox.Leave
If Not IntegerBetween(MyBox.Text, 1, 10) Then
MyBox.Text = 1
MyTab.Select()
MyBox.Select()
End If
End Sub
I looked for something similar to the "Handled" function that's present for keypressed as above in the tabs class but couldn't find anything.
Thank you very much.
Last edited: