Combobox value changes

6 posts, 0 answers
  1. Francis
    Francis avatar
    1 posts
    Member since:
    May 2009

    Posted 07 May 2009 Link to this post

    Hi,

    here is my problem :
    I have a radtabstrip with several tab items : the first item is a panel with a list of records, when you double click on a record, all the infos about the record are displayed in a new tab so a very easy application ...
    Some informations about records are displayed in combobox plugged on binding source (a new binding source is created for each new tab so that the combobox are not linked).

    The problem is when I open a second tab about a record, when I click on the tab of the first record, combo are initialized to the first value of the list and don't remember the initial value of the record :( The last tab item always have the right info in the combobox but all others tab items are reinitialized and I don't understand why :(

    Thank you for your help, if you have any question I'm here to explain better my problem ...

    Regards
  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 08 May 2009 Link to this post

    Hello Francis,

    Thanks for your questions.

    I will be very grateful if you can create a simple Windows Forms applications with a RadTabStrip control which can be used to reproduce the behavior you described. This will be of a great help to me when researching the issue and I will be able to provide a better solution. I am looking forward to receiving the details requested. Thanks for your time.

    Regards,
    Deyan
    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 13 Jul 2009 Link to this post

    I'm experiencing a similar issue.  It seems that the cbo_valueChanged event gets triggered when the cbo dataSource is set.  The event selects the first item in the dataSource list.  While this might be a desired process most of the time, It causes a problem when you want to set the selected value to something other than the 1st value.  Should one of the other events be used instead of the valueChanged?

    Thanks,
    Mike
  5. Mike
    Admin
    Mike avatar
    640 posts

    Posted 17 Jul 2009 Link to this post

    Hello MikeB,

    This behavior - the SelectedValue event is fired when you change the DataSource is by design. If you want to select another item after changing the DataSource you may store temporary the selected value and then restore it after the DataSource has been changed. The code may look like the following:

    int value = -1; 
    if (null != this.radComboBox1.SelectedValue) 
        value = (int)this.radComboBox1.SelectedValue; 
     
    this.radComboBox1.DisplayMember = "Display"
    this.radComboBox1.ValueMember = "Id"
    this.radComboBox1.DataSource = list; 
     
    if (value != -1) 
        this.radComboBox1.SelectedValue = value; 

    Let us know if the problem persists.

    Best wishes,
    Mike
    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.
  6. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 17 Jul 2009 Link to this post

    Hi Mike
    Thanks for the reply and the code snippet.  I was able to accomplish the same results with this:

                cboMultAccount.SelectedValueChanged -= cboAcct_ValueChanged;
                cboMultAccount.DataSource = acctList;
                cboMultAccount.SelectedValueChanged += cboAcct_ValueChanged;

    Is this common behavior (for the selected value to be set when the data source is set)?

    Thanks,
    Mike


  7. Nick
    Admin
    Nick avatar
    767 posts

    Posted 21 Jul 2009 Link to this post

    Hi MikeB,

    Thank you for contacting us back. Yes this is common because the CurrencyManager position is reset to 0.

    Kind regards,
    Nick
    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready