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.
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.