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

I cant remember exactly but i think ComoBox.SelectedItem or ComoBox.SelectedText will do the trick.

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";

only u have to write.

comboBox1.Text="";

only u have to write.

comboBox1.Text="";

only u have to write.

comboBox1.Text="";

??

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.