Default value in a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to have the word "Select" as the default option in a combo box
that will retrieve its data from database. I also would like to have the
ability to validate the combo box to ensure that the default option not used.
This combo box is complex bounded.
 
Add the select option to your data table that you are binding too.
Eg. dt.Rows.Add(new DataRow(-1, "SELECT", "some_other_column");
Then check in your validation code for selectedText = "SELECT"
(double check my property names)
 
Dave,

Although I find it an horrible solution, can you add with by instance the
DataTable LoadDataRow a datarow.

You have than to use a DataView to set the rows in the combobox in an
ordered way using the Sort.
You should than be sure that all the rows are filled in the "sort" column
and set that column in the LoadDataRow that you use for the "Select" on
spaces.

Most probably you will not succeed in that, because you want your display
member to be the sorted one.
But as you can, than this is easy. There are more ways, but are in my
opinion in fact all even more horrible if you use the value and the
displaymember.

I prefer just a label above the Combobox with in that "Select".

I hope this gives an idea,

Cor
 
Back
Top