help, TabControl1_SelectedIndexChanged fires on form initialize

  • Thread starter Thread starter Jeff C
  • Start date Start date
J

Jeff C

Hello all. Please please help me come up with a solution to this
problem.
Here it goes-
--- code snipit---

'TabControl1
'
Me.TabControl1.Anchor = System.Windows.Forms.AnchorStyles.Left
Me.TabControl1.Controls.AddRange(New
System.Windows.Forms.Control()
{Me.TabPage1, Me.TabPage2, Me.TabPage3})
Me.TabControl1.Enabled = False
Me.TabControl1.Location = New System.Drawing.Point(0, 40)
Me.TabControl1.Name = "TabControl1"
Offending Line---->>>>> Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(640, 384)
Me.TabControl1.TabIndex = 3
---------------------------------
When this control gets initialized it sets the selected index to 0,
thus firing the following code-

----------------
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged

Do your stuff here...

End Sub
------------

I do NOT want anything to happen when the form is initializing. How
can I catch this or stop it from happening?
I've tried to delete the offending line, but it comes back :o) ...
Any ideas?
To recreate,
Add tabcontrol to form, add a page or more to the tabcontrol.
Set the selected index changed event.
Run :o)

THANKS!
Jeff C.
 
\\\
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged

Static FirstChange as Boolean = True
If FirstChange = True then
FirstChange=False
Return
End If
Do your stuff here...

End Sub
///
 
Tricky tricky tricky :o)
Thanks,
I'll have to remember that loop with the static declaration.

Thank you very!!! much
Jeff
 
Back
Top