Edit this page

Data Binding

Data binding is a mechanism for automatic population of the RadMultiColumnComboBox with data, based on the provided data structure. Three properties control the data binding:

  • DataSource - specifies the data structure to be bound.

  • DisplayMember - specifies the particular field in the data source which will be used from the items in RadMultiColumnComboBox for the Text.

  • ValueMember - specifies the particular field in the data source which will be stored in the Value property.

RadMultiColumnComboBox supports data binding either at design time or at run time:

Data Binding at design time

You can set the DataSource property at design time in the Properties window of Visual Studio.

1. Select the DataSource property and click the drop-down arrow to display all existing data sources on the form.

Figure 1: DataSource

multicolumncombobox-databinding 001

This will force the RadGridView (contained in RadMultiColumnComboBox) to auto-generate columns for each field in the specified DataSource

2. Set the DisplayMember and ValueMember properties.

Figure 2: DisplayMember and ValueMember

multicolumncombobox-databinding 002

As a result RadMultiColumnComboBox is bound to the Northwind.Customers table:

Figure 3: Bound RadMultiColumnComboBox

multicolumncombobox-databinding 003

 Columns collection

You can set your own columns list using the Columns collection editor of RadGridView:

Figure 4: GridViewDataColumn Collection Editor

multicolumncombobox-databinding 004

The collection editor is accessible through the Columns property in the Properties grid:

multicolumncombobox-databinding 005

The important point when adding columns manually is to turn off the automatic generation of columns, otherwise you will have your columns duplicated in run time.

Adding columns

protected override void OnLoad(EventArgs e)

    NwindDataSet nwindDataSet = new NwindDataSet();
    CustomersTableAdapter customersTableAdapter = new CustomersTableAdapter();
    this.radMultiColumnComboBox1.DataSource = nwindDataSet.Customers;
    foreach (GridViewDataColumn column in

void SetUpGrid()
    RadGridView gridViewControl = this.radMultiColumnComboBox1.EditorControl;
    gridViewControl.MasterTemplate.AutoGenerateColumns = false;
    gridViewControl.Columns.Add(new GridViewTextBoxColumn("CustomerID"));
    gridViewControl.Columns.Add(new GridViewTextBoxColumn("ContactName"));
    gridViewControl.Columns.Add(new GridViewTextBoxColumn("ContactTitle"));
    gridViewControl.Columns.Add(new GridViewTextBoxColumn("Country"));
    gridViewControl.Columns.Add(new GridViewTextBoxColumn("Phone"));

Protected Overrides Sub OnLoad(ByVal e As EventArgs)
    Dim nwindDataSet As New NwindDataSet()
    Dim customersTableAdapter As New CustomersTableAdapter()
    Me.RadMultiColumnComboBox1.DataSource = nwindDataSet.Customers
    For Each column As GridViewDataColumn In Me.RadMultiColumnComboBox1.MultiColumnComboBoxElement.Columns
    Next column
End Sub
Private Sub SetUpGrid()
    Dim gridViewControl As RadGridView = Me.RadMultiColumnComboBox1.EditorControl
    gridViewControl.MasterTemplate.AutoGenerateColumns = False
    gridViewControl.Columns.Add(New GridViewTextBoxColumn("CustomerID"))
    gridViewControl.Columns.Add(New GridViewTextBoxColumn("ContactName"))
    gridViewControl.Columns.Add(New GridViewTextBoxColumn("ContactTitle"))
    gridViewControl.Columns.Add(New GridViewTextBoxColumn("Country"))
    gridViewControl.Columns.Add(New GridViewTextBoxColumn("Phone"))
End Sub

Data binding at run time

You can bind RadMultiColumnComboBox programmatically. It is necessary to set the DataSource, ValueMember and DisplayMember properties of RadMultiColumnComboBox.

Binding at run time

this.radMultiColumnComboBox1.DisplayMember = "LastName";
this.radMultiColumnComboBox1.ValueMember = "EmployeeID";
this.radMultiColumnComboBox1.DataSource = this.employeesBindingSource;

Me.RadMultiColumnComboBox1.DisplayMember = "LastName"
Me.RadMultiColumnComboBox1.ValueMember = "EmployeeID"
Me.RadMultiColumnComboBox1.DataSource = Me.EmployeesBindingSource

See Also