load ComboBoxBase from xml

Hi,
I'm trying to load data into a ComboBoxBase using this code. I only get one row. The samples only have mdb data sources. I would ultimately like the choice picked in the combo to drive the items displayed in adjacent text boxes, so that I have a kind of record browser.

Can you help?

Thanks,

this.dsList = new DataSet();
this.dsList.ReadXml("List.xml");
this.cmbPortfolios.DataBindings.Add("Text", this.dsList.Tables["Lists"], "description");

3 Replies

AD Administrator Syncfusion Team January 29, 2007 05:43 PM UTC

Hi Dimitri.

The Combobox doesn't have a DataMember property - instead it has a DisplayMember and ValueMember property. The DisplayMember of a Combobox gets or sets a string that specifies the property of the data source whose contents you want to display. The ValueMember property determines which value gets moved into the SelectedValue of the Combo Box.

In the example, whenever the user selects a Customer by "Customers.CompanyName", the SelectedValue is the "Customers.CustomerID". Whenever the SelectedValue changes, the data-binding moves the new value into the Customer object.

// Setup the combobox view and display-, value member
comboBox.DataSource = dsView;
comboBox.DisplayMember = "Customers.CompanyName";
comboBox.ValueMember = "Customers.CustomerID";

Best Regards,
Haneef


AD Administrator Syncfusion Team January 30, 2007 02:09 PM UTC

Thanks Haneef,
The examples use a database - I'm not having a lot of luck using xml - is there a sample driven totally by xml?



>Hi Dimitri.

The Combobox doesn't have a DataMember property - instead it has a DisplayMember and ValueMember property. The DisplayMember of a Combobox gets or sets a string that specifies the property of the data source whose contents you want to display. The ValueMember property determines which value gets moved into the SelectedValue of the Combo Box.

In the example, whenever the user selects a Customer by "Customers.CompanyName", the SelectedValue is the "Customers.CustomerID". Whenever the SelectedValue changes, the data-binding moves the new value into the Customer object.

// Setup the combobox view and display-, value member
comboBox.DataSource = dsView;
comboBox.DisplayMember = "Customers.CompanyName";
comboBox.ValueMember = "Customers.CustomerID";

Best Regards,
Haneef


AD Administrator Syncfusion Team January 31, 2007 07:51 PM UTC

Hi Dimitri,

Please try the sample and let me know if you are looking something different.
comboBox.zip

Best Regards,
Haneef

Loader.
Up arrow icon