like we clear textbox item txtname.clear()..
so how we can bring combo box main item....
i have combo box of date...
and text of combo box is "Select Date"
after insertin the data i want to bring back "select Date" on combo box..
Hope someone will help me..
Regards..
Farhad

Assuming the text "-- Select Date --" is the first item in the box, then this will work:

comboBox1.SelectedIndex = 0;

Note that even when yo do this in code, it will cause the "SelectedIndexChanged" event to fire for the combo box.

comboBox1.Text

//an example code:
comboBox1.Items.AddRange(new string[] { "item 1", "item 2", "item 3" });
comboBox1.Text = "Select date";

property will do it ones again!
But I would like to ask you how do you populate data into comboBox?

If you use a dataSouce, you have to call the Selectedindex property and set it to -1, so no item from a dataSource will be choosen on the show.
Example.

string[] array = { "a", "b", "c" };
            comboBox1.DataSource = array;
            comboBox1.SelectedIndex = -1;
            comboBox1.Text = "Select date";
comboBox1.Text

//an example code:
comboBox1.Items.AddRange(new string[] { "item 1", "item 2", "item 3" });
comboBox1.Text = "Select date";

property will do it ones again!
But I would like to ask you how do you populate data into comboBox?

its working now...i m too stupid why i got this idea..i have already used it many times :)

This article has been dead for over six months. Start a new discussion instead.