Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to set a default value for a Combo Box in c#.net?

i want to bind first "---select---" after datasourse contains comapny name

like

--selct--
india
shrilanka
USA
Canada


thanks in advance
Posted

Insert this "---Select---" as an item in the data source collection and set selected index property of combobox to the corresponding index of that object.
 
Share this answer
 
Amit, you may be binding your values to the combobox from the database and then you may need to insert "--Select--" at the top. For this you can use the code given below,


comboBox1.Items.Insert(0, new ListItem("--Select--","0"));


This will do the bit you need.

Anurag
@cheers@
 
Share this answer
 
you can insert data in combobox by

<pre lang="cs">private void Form1_Load(object sender, EventArgs e)
{
comboBox1.Items.Add(select);
<pre lang="sql">comboBox1.Items.Add(jaipur);</pre>

}</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900