Unexpected Binding Results

2 posts, 0 answers
  1. Jerel
    Jerel avatar
    7 posts
    Member since:
    Feb 2009

    Posted 19 Mar 2009 Link to this post

    I have a RadComboBox on my WinForm (using the latest 2009 release), whose DataSource I am setting to an Array of Objects, similar to...

    BankInfo[] infos = GetBankInfos();
    bankInfoCombo.DataSource = infos;

    I also have a BindingSource on the form that takes a List of Objects, similar to...

    List<Bank> banks = GetBanks();
    bankBindingSource.DataSource = banks;

    I am using this BindingSource to bind the controls on the form to the Bank objects properties, of which one of them is ReturnProcessor of Type BankInfo.

    this.bankInfoCombo.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bankBindingSource, "ReturnProcessor", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));

    When using a WinForm ComboBox, if I choose not to set the DisplayMember or ValueMember, the ComboBox will call ToString() on the Array and use that as the DisplayMember and the Object as the ValueMember.

    The behavior I am getting out of the RadComboBox however, is that if I do not set the ValueMember, nor the DisplayMember it will still ToString() the object, but the SelectedValue will always be null. What occurs, because of this behavior, is that my Databound object ReturnProcessor value is always null, even after a Value is selected from the ComboBox.

    The Work around that I have found is to Sub Class the object with a new Property of ReturnProcessorObjectID of Type long. And set the ComboBox DisplayMember to BankName and ValueMember to ObjectID. Then I bind the ComboBox to ReturnProcessorObjectID, instead of the Real ReturnProcessor object.





  2. Deyan
    Deyan avatar
    2147 posts

    Posted 23 Mar 2009 Link to this post

    Hello Jerel,

    Thanks for contacting us and for the details provided.

    In fact, this is an undesired behavior in RadComboBox and I have put it in our ToDo list for future releases. However, since we are under tight schedule due to tasks with higher priority, I cannot give you an exact timeframe when this will be implemented.

    I am sorry for the inconvenience caused. I have also updated your Telerik points for pointing this out.

    Best wishes,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top