I have a custom control in which I want to perform some data validation in the OnValidating event. If the data is invalid, the control sets the CancelEventArgs's Cancel property to true to reset the focus back to the control.
This all works fine until I host this control on a tab page. If the user enters invalid data into the control then directly clicks on another tab, the validating event gets fired several times in succession, and the tab page changes anyway.
Is there a way to prevent the tab page from being changed in this secnario

Validation & Tab Control
nsimeonov
Public Class MyTextbox
Inherits TextBox
Protected Overrides Sub OnValidating(ByVal e As System.ComponentModel.CancelEventArgs)
e.Cancel = True
MyBase.OnValidating(e)
End Sub
End Class
Miles Cohen
vb example..
Private Sub TabControl1_SelectedIndexChanged(...)...
If somebooleanvariable = False Then
TabControl1.SelectedTab = TabPage1
End If
End Sub