ToolstripComboBox

Moorzee

Well-known member
Joined
May 31, 2006
Messages
92
Location
England
Programming Experience
3-5
Has anyone ever used this as a normal combobox i.e with a diplsymember and valuemember?

I have been killing myself with this for a while now!

There is an underlying ComboBox which I have set datasource,displaymember, and valuemember but cannot use.......

Please someone put me out of my misery. Toes are curling up in frustration and grinding my teeth!!!:(

Ta.
 
About combo binding, ToolStripComboBox class has got a ComboBox property that expose the regular ComboBox control it hosts (doc: "to get properties, methods, and events that have not been wrapped"), which should allow you to treat it as such also.

Another option is to use the ToolStripControlHost to add a regular ComboBox control, which you bind.
 
YES! That works!

JohnH, thanks! That worked.

Just use toolstripcombobox1.combobox.datasource, .valuemember, and .displaymember

I search about 6 google hits before I found this.
 
I tried the same thing and can confirm that the items are not displayed. I checked the DataSource property of the control at various points and it was set to a table but no items were displayed. I have no idea why this would be the case but I'd agree that it must be a bug. You should report it to Microsoft but in the meantime you could get around it by just adding the items manually and using a keyed collection to setup the correspondence between the two properties if required.

Sorry to "bump" such an old post, but I am curious to know whether this "bug" has ever been addressed? I'm having the exact same issue in VS Express for Desktop.
 
The BindingContext property of the hosted ComboBox is not initialized when it is added as subitem in toolstrip, set it to for example same object as the forms BindingContext property - that is default for comboboxes you add directly to a form and for strip top-level ToolStripComboBoxes.
 
Back
Top