Problem with Bindind combobox and SelectedIndex Changed

8 posts, 0 answers
  1. Pramod Goutham
    Pramod Goutham avatar
    19 posts
    Member since:
    Aug 2008

    Posted 23 Nov 2008 Link to this post

    Hi,

    Whenever I bind my radcomboxbox with a table in the dataset, the SelectedIndex Changed event gets fired automatically, causing exceptions in my winform, since I'm writing the SelectedIndex Changed event to retrieve some more data from the DB based on the value of the item selected in the radcombo box.

    The code I have written is as below:

    DataSet mydataset = helperObj.GetData();
    radcombobox1.DataSource = mydataset.Tables[0];
    radcombobox1.Text = "Please Select";

    How can I avoid the event from being fired?

    Thanks and Regards,
    Pramod Goutham.
  2. Vassil Petev
    Admin
    Vassil Petev avatar
    1765 posts

    Posted 26 Nov 2008 Link to this post

    Hi Pramod Goutham,

    Indeed, this is an issue that will be addressed soon. Thank you for reporting it.


    Best wishes,
    Vassil
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marcus Eddy
    Marcus Eddy avatar
    26 posts
    Member since:
    Jun 2008

    Posted 27 Jan 2009 Link to this post

    The only way I found to get around this is subscribe and unsubscribe to the SelectedIndexChanged event programmatically before and after databinding, this way I had control over this event and could circumvent the inbuilt method calls.
  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 29 Jan 2009 Link to this post

    Thank you for sharing with the community your work-around, Marcus Eddy.

    Best wishes,
    Nick
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Diederik
    Diederik avatar
    12 posts
    Member since:
    Feb 2009

    Posted 31 Jul 2009 Link to this post

    Hi,

    Is this problem solved in the 2009 Q1SP1 release? I am trying to bind a list of custom objects and the SelectedIndexChanged event triggers automatically.

    Best regards.
  7. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 31 Jul 2009 Link to this post

    Hello Diederik,

    This bug is not fixed yet and you should use the workaround from Marcus Eddy.

    Please, excuse us for the inconvenience. The issue is logged in our TODO list and it will be addressed in some of the next releases. Don't hesitate to contact us if you have other questions.

    Sincerely yours,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. southwynd
    southwynd avatar
    11 posts
    Member since:
    Jul 2009

    Posted 08 Sep 2009 Link to this post

    I'm having this same issue.  I want to populate a RadGridView, but only after selecting an item from the RadComboBox  I've attempted to remove/add the SelectedIndexChanged event like this:

        Private Sub ddlProtocols_ItemDataBound(ByVal sender As ObjectByVal e As ItemDataBoundEventArgs) Handles ddlProtocols.ItemDataBound 
            AddHandler ddlProtocols.SelectedIndexChanged, AddressOf ddlProtocols_SelectedIndexChanged 
     
            ' My code here for formatting RadComboBoxItem tags
     
            RemoveHandler ddlProtocols.SelectedIndexChanged, AddressOf ddlProtocols_SelectedIndexChanged 
        End Sub 

    And then populate my RadGridView like this:

        Private Sub ddlProtocols_SelectedIndexChanged(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles ddlProtocols.SelectedIndexChanged 
            ' My code here for populating the RadGridView
        End Sub 

    But the SelectedIndexChanged continues to fire multiple times before I've selected an item from the RadComboBox.  Any ideas on how I can get this workaround to work?
  9. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 11 Sep 2009 Link to this post

    Hello southwynd,

    Thank you for writing. You should unsubscribe from the event before the databinging and subscribe after that. Please, refer to the code snippet:
     
    RemoveHandler ddlProtocols.SelectedIndexChanged, AddressOf ddlProtocols_SelectedIndexChanged  
     
    me.radGridView1.DataSource = table1 
     
    AddHandler ddlProtocols.SelectedIndexChanged, AddressOf ddlProtocols_SelectedIndexChanged  
     
     

    Hope this helps.

    Kind regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for WinForms is Visual Studio 2017 Ready