Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

already i have binded some data to combobox from the database. i want to display first item in combobox as Select. [so i want to add both text and value in combobox]

in web application we used to add as follows
C#
ddlEmpId.Items.Insert(0, "--Select--");

Like this i want to add for combobox in window Application.

Think so u got my point.
Posted
Updated 17-Aug-12 11:12am
v2

C#
this.comboBox1.Items.Insert(0, "Data");

Nothing new here. Have a read complete article to explore more
Add Item to Binded Combo Box[^]
http://msdn.microsoft.com/en-us/library/aa983551%28v=vs.71%29.aspx[^]
 
Share this answer
 
Comments
Shivani Dash 17-Aug-12 8:32am    
it nt wrkd...it shows "Items collection cannot be modified when the DataSource property is set." error
 
Share this answer
 
C#
this.comboBox1.DisplayMember = "PersonName";
this.comboBox1.ValueMember = "PersonID";
 
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