Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initial Value of Combo Box

Status
Not open for further replies.

BKer

Programmer
Apr 17, 2001
62
US
I have a combo box that is populated from a db, but i cannot figure out how to set the first item in the list to "Select an Item". Can anyone tell how I can do this? Here is my code for filling the combo box.

With cboTagname
.DataSource = dvTagname
.DisplayMember = "col001"
.ValueMember = "col001"
End With

Thanks in advance for the help
BK
 
BK
If you don't need "Select An Item" to have a value, you can just set the .text property to "Select An Item."
 
If you want the "Select..." text to be the first item, you need to insert it into the datasource that the combo is bound to, before binding. Something like:
Code:
Dim dr As DataRow = DataTable.NewRow

dr(0) = 0
dr(1) = "Select An Item"

DataTable.Rows.InsertAt(dr, 0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top