TabControl - Suppress Event on Load

  • Thread starter Thread starter theintrepidfox
  • Start date Start date
T

theintrepidfox

Dear Group

Just wondered whether you have any advice on the following?

I have a form with a TabControl and when the form loads, the
SelectedIndexChanged event is fired. Is there any chance to suppress
this event when the form loads but enable it once the form has finished
loading?

I'm very grateful for any hints as I've wasted two days so far on
finding a solution.

Many thanks for your time and efforts!
Have a nice day!

Martin
 
remove the 'Handles MyTabControl.SelectedIndexChanged' from the end of the
sub and add

AddHandler MyTabControl.SelectedIndexChanged, AddressOf
MyTabControl_SelectedIndexChanged

to Form_Load()

or alternatively, add a Static flag to the event so that it ignores the
first change.

\\\
Sub MyTabControl_SelectedIndexChanged(...) Handles ...
Static FirstChange As Boolean = False
If FirstChange = False then
FirstChange = True
Return
End If
'Your code here
End Sub
///

This does not happen in C# because the handler is added in the Forms
InitializeComponent Method.
 
Back
Top