Actually, acting out my brain here, and I'm sure it's simple that I miss.
Basically, I have a form with two tabs. I check the controls on each tab to make sure they are dirty and you want the user not to click the tab if there are changes in the current tab.
I thought that if you check the dirty variable and just set the tab index to the one that was not selected, everything will be fine, but every time I set the tab property programmatically, it starts a bunch of event tabs that just create an undesirable result, such as the right control set until the wrong tab is displayed.
Here is the code as close as possible to make it work.
Private Sub objTabs_Selected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles objTabs.Selected If bIsDirty Then If Me.objTabs.SelectedIndex = 1 Then Me.objTabs.SelectedTab = tabLetterofCreditBanks Me.objTabs.SelectTab(0) Else Me.objTabs.SelectedTab = tabWireTransferBanks Me.objTabs.SelectTab(1) End If End If End Sub
Thanks in advance.
source share