Posts Tagged ‘cancel’

Cancel a tab change in Dotnet Winforms

August 24th, 2010

For Dotnet2 and lower there was no easy way of stopping a user from switching a tab in a tab control.  I have written a solution in Dotnet compact framework (2?) that inherited from TabControl and overrided a couple of methods that together with a flag or two made it possible to cancel tab switching.  If I recall correctly it never stopped the control from blinking but it did it’s job.  It wasn’t hard but it took some hours.  If you are forced to implement this in Dotnet2 you have to inherit, the overridable methods used do not all send an event.

With Dotnet 3 to the current 4 it is easier.  Just associate a method with the Selecting event.

I did it in Dotnet3.5 and noticed some flickering when trying to, and cancelling, the change of tab.