This is very weird ! ...
I am handling by code the current page of a tab page control and I'm facing something weird !
I have 6 tabs on the tab control but very often although I set one as current tab (for example the 4th tab) , the 4th tab does get selected but the page under the tab is the wrong one ! For example it could be the 6th page that's being shown !
I can't understand how could this happen ! As far as I am concered , each page of the tab control is strictly tied to its correspondent tab . You can't just select a tab and view another page ! ! ! !
Let me specify that I am not using any code to draw the tab page . My tab control is as it is provided by the Editor (from the Tools tab) .
In order to help you , let me tell you that the problem appeared when I added code in the form so that a specific tab will always be back on . You see I want the tabs to be changed only by code , not by the user (in order to avoid him selecting a wrong page) . So each time the selected tab is changed , the SelectedIndex event sets to a variable the number of the tab . When the user clicks or doubleclicks the tab control , those events turn back the correct tab . Here's the code used :
on which , the AllowSettingLockedTabIndex is a variable declared in a module and determines (as shown above) if the changed tab will be stored or not .
I am handling by code the current page of a tab page control and I'm facing something weird !
I have 6 tabs on the tab control but very often although I set one as current tab (for example the 4th tab) , the 4th tab does get selected but the page under the tab is the wrong one ! For example it could be the 6th page that's being shown !
I can't understand how could this happen ! As far as I am concered , each page of the tab control is strictly tied to its correspondent tab . You can't just select a tab and view another page ! ! ! !
Let me specify that I am not using any code to draw the tab page . My tab control is as it is provided by the Editor (from the Tools tab) .
In order to help you , let me tell you that the problem appeared when I added code in the form so that a specific tab will always be back on . You see I want the tabs to be changed only by code , not by the user (in order to avoid him selecting a wrong page) . So each time the selected tab is changed , the SelectedIndex event sets to a variable the number of the tab . When the user clicks or doubleclicks the tab control , those events turn back the correct tab . Here's the code used :
Code:
Private Sub TabControlMY_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControlMY.SelectedIndexChanged
If AllowSettingLockedTabIndex = True Then
IndexOfLockedTab = TabControlMY.SelectedIndex
AllowSettingLockedTabIndex = False
Else
TabControlMY.SelectedIndex = IndexOfLockedTab
AllowSettingLockedTabIndex = True
End If
End Sub
Private Sub TabControlMY_Click_Or_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControlMY.Click, TabControlMY.DoubleClick
AllowSettingLockedTabIndex = False
End Sub