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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top