Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Filling a drop down combo box on the toolstrip
 

Filling a drop down combo box on the toolstrip

I see how to add a data source to a combo box on a windows form but when you add a combo box via the tool bar it doesn't seem to be able to bound to a data source!

Is this correct?

If so how would i display a tableadapter in this combo box?

Regards Darren.

dazza33  Monday, July 17, 2006 12:14 AM

try:

toolStripComboBox1.ComboBox.DataSource = new DataTable();

or whatever the datasource is. The ComboBox is a property of the ToolStrip Container... If that is worded correctly...

Hope that works for ya.

aztec2_step  Monday, July 17, 2006 12:38 AM

The combo box doesnt seem to be a property of the toolstrip but a property of the form.

Darren.

dazza33  Monday, July 17, 2006 1:05 AM

HI. guy..

below is my repro for bind datatable to toolstrip combox component, it work well.

maybe would give you something.

this.dataSet1.DataTable1.AddDataTable1Row("xin1");
this.dataSet1.DataTable1.AddDataTable1Row("xine2");
this.dataSet1.DataTable1.AddDataTable1Row("xine3");
this.dataSet1.DataTable1.AddDataTable1Row("xine4");
this.dataSet1.DataTable1.AddDataTable1Row("xine5");

this.toolStripComboBox1.ComboBox.DataSource = this.dataSet1.DataTable1;
this.toolStripComboBox1.ComboBox.DisplayMember = "Text";
this.toolStripComboBox1.ComboBox.Text = "";

note:

the dataset1 is a typed dataset , with a table named "DataTable1" that have two column ,"ID" and "Text",

private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Console.WriteLine(((System.Data.DataRowView)this.toolStripComboBox1.ComboBox.SelectedItem).Row["ID"].ToString());
}

in the SelectedIndexChanged EventHandler, the Combox.SelectedItem object Type is DataRowView.

Greetz!

Matt Lin  Monday, July 17, 2006 2:24 AM

Actually i may have misled you all, the combo actually resides in a drop down menu wich lives on the tool strip.

Darren.

dazza33  Monday, July 17, 2006 2:49 AM

You can use google to search for other answers

Custom Search

More Threads

• DataGridComboBoxColumn Sorting on Foreign Key Index Rather than Foreign Value
• NoNullAllowedException when trying to cancel out of new record add
• Gridview Sort Arrows
• Oracle Database and DataGridView Behind Code Programming without DataSource to Display Information Problem
• Is it possible to automatically import unique constraints into DataSet?
• Terminating asynchronous delegate
• bound DataGridView alway reset display position on DataSource updates
• Reg binding a image from a Database to combobox
• Datagridviewcombobox change datasource throws "datagridviewcomboboxcell value is not valid"
• Datagrid update problem with datarow.