in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

C1DockingTab SelectedIndexChanged Event Fires On Init

Last post 10-22-2007 6:24 PM by rooflogic. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-19-2007 3:21 PM

    C1DockingTab SelectedIndexChanged Event Fires On Init

    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.

     

  • 10-22-2007 4:45 PM In reply to

    Re: C1DockingTab SelectedIndexChanged Event Fires On Init

     The code that actually sets the selected index and fires the event is needed to properly initialize the control, but I guess you're right and it is better not to fire the event in this case. This will be fixed in the T3 release (which should be available for download as a pre-release pretty soon). Thanks.

    Cheers,
    Dima.
  • 10-22-2007 6:24 PM In reply to

    Re: C1DockingTab SelectedIndexChanged Event Fires On Init

    Thanks!

Page 1 of 1 (3 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.