Combo Box DropDown Style

  • Thread starter Thread starter kashifsulemani
  • Start date Start date
K

kashifsulemani

Combo Box DropDown Style.

A combo box is bound to a data table field name.
When combo box has simple / drop down style then bound is successful.

Other hand if Combo box has drop down list style then bound is
successful but combo box not show data field names.

E.g

1.

cmbName.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList ;
cmbName.DataBindings.Clear();
cmbNameOTR.DataBindings.Add("text", dt, dt.Columns["Name"].Caption);



Here in above code data binding is successful but did not show
anything.


2.

cmbName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown ;
cmbName.DataBindings.Clear();
cmbNameOTR.DataBindings.Add("text", dt, dt.Columns["Name"].Caption);



Here in this example when combo box has Simple or drop down style then
it responses good, with data binding and displaying data as well.
 
Are you sure you want to bind to the column in dt that is reflected by
caption? You should be using "Name" instead as the property to bind to, not
what is returned by the Caption property.

Hope this helps.
 
Back
Top