private void MultiColumnComboBox1_MouseDown(object sender, MouseEventArgs e)
{
if (this.multiColumnComboBox1.DataSource == null)
{
//Create dataTable
DataTable dt = new DataTable("Table1");
dt.Columns.Add("FirstName");
dt.Columns.Add("LastName");
// Create a Data Set
DataSet ds = new DataSet();
ds.Tables.Add(dt);
dt.Rows.Add(new string[] { "John", "Tina" });
dt.Rows.Add(new string[] { "Mary", "Anu" });
DataView view = new DataView(dt);
// DATASOURCE is DATAVIEW
this.multiColumnComboBox1.DataSource = view;
this.multiColumnComboBox1.DisplayMember = "FirstName";
this.multiColumnComboBox1.ValueMember = "LastName";
this.multiColumnComboBox1.SelectedIndex = -1;
this.multiColumnComboBox1.Text = string.Empty;
}
} |