I am trying to populate a combobox with a lisy of items. I want the 1st item
to be "Make a Selection" and the following items will be names from a table
in my DB (See code below).
When I run the project, the combox box initially displays an empty
selection. When I click on the drop down arrow I see the "Make a Selection"
followed by the other choices.
How can I move everything up so that the "Make a Selection" is the default
value in the combo box?
Wayne
============= code =============== =
Dim cn As New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=c:\Progr am Files\MyApp\MyD ata.mdb")
strSQL = "SELECT Name FROM Table1 WHERE (EQ = Yes) Order By Name"
cn.Open() 'Open the connection
Dim cmd As New OleDbCommand(st rSQL, cn)
Dim rdr As OleDbDataReader = cmd.ExecuteRead er
cboSample.Items .Clear()
cboSample.Items .Add("Make a Selection")
While (rdr.Read())
cboSample.Items .Add(rdr.GetStr ing(0)) ' Name is the only field returned
End While
rdr.Close()
--
------------------------------------
Wayne Wengert
wayne@wengert.o rg
to be "Make a Selection" and the following items will be names from a table
in my DB (See code below).
When I run the project, the combox box initially displays an empty
selection. When I click on the drop down arrow I see the "Make a Selection"
followed by the other choices.
How can I move everything up so that the "Make a Selection" is the default
value in the combo box?
Wayne
============= code =============== =
Dim cn As New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=c:\Progr am Files\MyApp\MyD ata.mdb")
strSQL = "SELECT Name FROM Table1 WHERE (EQ = Yes) Order By Name"
cn.Open() 'Open the connection
Dim cmd As New OleDbCommand(st rSQL, cn)
Dim rdr As OleDbDataReader = cmd.ExecuteRead er
cboSample.Items .Clear()
cboSample.Items .Add("Make a Selection")
While (rdr.Read())
cboSample.Items .Add(rdr.GetStr ing(0)) ' Name is the only field returned
End While
rdr.Close()
--
------------------------------------
Wayne Wengert
wayne@wengert.o rg
Comment