Turn off calling tabPage_Enter method in C #

When I switch tabs with the following code

tabControl1.SelectTab("MyNextTab");

      

It calls tabPage_Enter for the tab it is switching from and the tab it is switching to. I want it to be called for the tab it switches to, but not the taboo it switches from. How would I disable this. I know when this happens, so if there was a call I could make it would disable the call to the input method for that tab that I could implement.

+1


source to share


3 answers


Yes, I repeat if I use the button to change the selected tab. The TabControl forces focus on itself before it changes the SelectedIndex. Apparently this was done to avoid problems with the Validating event. A focus change will result in the first Enter event, for the active tab, the tab will change and then fire a second Enter event.



Knowing this, you can set up an auxiliary boolean by specifying that the first Enter event should be ignored. Be careful to check that the current tab is not the one you want to select. In an ideal world, this behavior shouldn't matter. The focus has indeed moved to the active tab.

+2


source


Can you check active tab index and workaround using this?



0


source


Wrap the code in an event inside a validation so that it only gets processed when you want it.

If you can write code to disable it, you can write code to set the state that prevented the code from running on the event.

0


source







All Articles