Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to insert an item in 0th index in combox?
Posted
Updated 1-Aug-12 1:36am
v2
Comments
Sebastian T Xavier 1-Aug-12 8:15am    
What? Is this comment relevant, based on this question?
Kenneth Haugland 1-Aug-12 8:26am    
If he is binding the combobox item to a list it is, but I guess you are right....
Sebastian T Xavier 1-Aug-12 8:32am    
Fine, anyway that comment is deleted , it seems...

Please try the following...

C#
comboBox1.Items.Insert(0, objectname);


Regards
Sebastian
 
Share this answer
 
hi kamala ,
by default it will take zero index onwards , other wise u can give below

select combobox --->goto properties ---->Items ----->click on add --->see the properties(right side) --> give content name and check the checkbox ISSelected -->then click on Ok.
 
Share this answer
 
Comments
Unareshraju 1-Aug-12 8:25am    
r u asking at designing time right!.
Sebastian T Xavier 1-Aug-12 8:33am    
May not be....
Hi,
Try this,
C#
comboBox1.Items.Insert(0, new ComboBoxItem("Select", string.Empty));



--Amit
 
Share this answer
 
v2
Comments
Sebastian T Xavier 1-Aug-12 8:01am    
Will Items.add() accept more than one parameter?
C#
List<listitems> CreditStatuses = new List<listitems>(){
               new ListItems(){Code="PN",Name="Pending"},
               new ListItems(){Code="APP",Name="Approved"},
               new ListItems(){Code="RJ",Name="Rejected"}
           };

            Select_CreditStatus.DataSource = CreditStatuses;
            Select_CreditStatus.DataTextField = "Name";
            Select_CreditStatus.DataValueField = "Name";
            Select_CreditStatus.DataBind();
            Select_CreditStatus.Items.Insert(0, new ListItem(String.Empty, String.Empty)); </listitems></listitems>
 
Share this answer
 
Hi kamal,
Try to use Text property of combobox.
Example1 :-
ArrayList al = new ArrayList(5);
al.Add("sunil1");
al.Add("sunil2");
al.Add("sunil3");
al.Add("sunil4");
al.Add("sunil5");
comboBox1.DataSource = al;

comboBox1.Text = "select one";
 
Share this answer
 
Comments
Santhosh Kumar Jayaraman 1-Aug-12 10:40am    
Did it work? I am not sure whether this will work

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