This is a migrated thread and some comments may be shown as answers.

Unexpected Binding Results

1 Answer 47 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jerel
Top achievements
Rank 2
Jerel asked on 19 Mar 2009, 03:10 PM
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.

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 23 Mar 2009, 07:22 PM
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,
Deyan
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Jerel
Top achievements
Rank 2
Answers by
Deyan
Telerik team
Share this question
or