v2.0.20072.19209
I have a C1DockingTab control on a form and I want to use the SelectedIndexChanged event to run code when the user changes tabs. However, I have found that the SelectedIndexChanged event is also fired when the form's controls are being initialized (InitializeComponent()). The code that runs in the SelectedIndexChanged event does things that I don't want done when the form is initially loading/displaying. Not only that, the code accesses other resources that are not yet initialized when the InitializeComponent() method is run and thus causes a runtime error.
Why in the world would the C1DockingTab fire the SelectedIndexChanged event on initialization!? And, is there any way around it?
I have confirmed this problem in a simple project:
1) Create a new Project
2) Add a C1DockingTab control to Form1
3) In the Form1 constructor (after the call to InitializeComponent()), initialize the Tag property of c1DockingTabPage1 to a string value:
c1DockingTabPage1
.Tag = "Test";
4) Enter code for the SelectedIndexChanged event of the C1DockingTab control to show the value of the C1DockingTab.SelectedTab.Tag property:
MessageBox.Show(c1DockingTab1.SelectedTab.Tag.ToString());
5) Run the project.
When it breaks look at the call stack. It is running the SelectedIndexChanged event when ((System.ComponentModel.ISupportInitialize)(this.c1DockingTab1)).EndInit(); is called in the form's InitializeComponent() method.