Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to set the first item in a combo box to the default option. Can anyone help me with that?
Posted
Comments
Winston Madiano 25-Jul-13 22:45pm    
Duplicate question..
syed shanu 25-Jul-13 23:00pm    
Do you mean like this
ComboBox.SelectedIndex=0
Sergey Alexandrovich Kryukov 26-Jul-13 1:09am    
When you say ComboBox, always provide a fully-qualified type name. There are different classes in different libraries.
—SA

Set selected index for a required item that may be resolve the issue
 
Share this answer
 
I hava alredy your question here :Combo boxes help, set first character to default[^]


another way:

"01:red"
"04:green"
"09:blue"
"023:black"

initial:

Combo1.Text = Combo1.List("023")
 
Share this answer
 
I assume you have binded your combobox in codebehind.
C#
Dim cmd As New SqlCommand(Query, connection)
Dim dt As New DataTable()
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt)
Dim dr As DataRow = dt.NewRow()
dr("column name") = "Your default text here"//We created default row that needs to be entered at first position 
dt.Rows.InsertAt(dr, 0)//Inserted at first place
ComboBox.DataSource = dt
ComboBox.DataBind()

Regards..:laugh:
 
Share this answer
 
v5

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