Possible cross thread issue?

2 posts, 0 answers
  1. Mike Baldini
    Mike Baldini avatar
    11 posts
    Member since:
    Feb 2010

    Posted 04 May 2010 Link to this post

    We have a RadTabStrip control that has listboxes and combo boxes located on each TabItem.

    The issue we are running in to is populating the BindingSources for each combo box on the RadTabStrip.TabSelected event.

    On form load, we have the following code:
            void Form1_Load(object sender, EventArgs e) 
            { 
                PopulateOutTabCombo(); 
                PopulateOutTabList(); 
                this.radTabStrip1.SelectedTab = tabItem2; 
            } 
     
            void PopulateOutTabCombo() 
            { 
                DataItem2Manager dm2 = new DataItem2Manager(); 
                this.outTabComboSource.DataSource = dm2; 
            } 
            void PopulateOutTabList() 
            { 
                DataItem1Manager dm1 = new DataItem1Manager(); 
                this.outTabListSource.DataSource = dm1; 
            } 


    The routine that handles the radTabStrip1.SelectedTab event has the following code:
            void radTabStrip1_TabSelected(object sender, Telerik.WinControls.UI.TabEventArgs args) 
            { 
                PopulateInTabCombo(); 
                PopulateInTabList(); 
            } 
     
            void PopulateInTabCombo() 
            { 
                DataItem2Manager dm2 = new DataItem2Manager(); 
                this.inTabComboSource.DataSource = dm2; 
            } 
            void PopulateInTabList() 
            { 
                DataItem1Manager dm1 = new DataItem1Manager(); 
                this.inTabListSource.DataSource = dm1; 
            } 

    When the SelectedTab changes to tabItem2 on the form load event, the BindingSource does not get populated with any data, even though the code is being run.

    Even more interesting, if you breakpoint the code 'this.inTabComboSource.DataSource = dm2;', you can see that the BindingSource.Count = 0, BUT.... the BindingSource.DataSource property has 10 items in it!

    This ONLY happens when you programmatically switch the SelectedTab. If the user clicks on the tab to switch it, it works perfect! Is there some cross thread issues going on that I am not seeing?

    After the form loads, if you manually switch the tabs, the BindingSource will be populated, and you will get the items in the combo box and list box.

    You can download a copy of my sample solution if you need to reproduce the issue.

    Has anyone else run into this problem? If so, have you been able to solve it?
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 10 May 2010 Link to this post

    Hello Mike Baldini,

    Thank you for writing.

    The reason nothing is happening lies in the fact that the TabSelected event does not fire initially. This in turn is happening because the initially selected tab is tabItem2. You are attempting to select it and when RadTabStrip sees that you are passing the same tab item as the selected tab item it does nothing.

    Please write again if you need further assistance.

    Greetings,
    Victor
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top