T
Tor Inge Rislaa
Avoid autoselect in combobox
In the load procedure of a form I am filling a combobox with data from a
database. The combobox fill the data OK, but it is automatic showing the
first item of the list as the text. How can I avoid the first item in the
list to be selected as default? I want the textbox of the combo to be left
empty until the user select an item.
My Code below:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
MyDataAdapter.SelectCommand.CommandText = "SELECT MyDescription, MyID
FROM MyTable"
MyDataAdapter.Fill(MyDataSet)
ComboBox1.DataSource = MyDataSet
ComboBox1.DisplayMember = "MyTable.MyDescription"
ComboBox1.ValueMember = "MyTable.MyID"
End Sub
T.I.Rislaa
In the load procedure of a form I am filling a combobox with data from a
database. The combobox fill the data OK, but it is automatic showing the
first item of the list as the text. How can I avoid the first item in the
list to be selected as default? I want the textbox of the combo to be left
empty until the user select an item.
My Code below:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
MyDataAdapter.SelectCommand.CommandText = "SELECT MyDescription, MyID
FROM MyTable"
MyDataAdapter.Fill(MyDataSet)
ComboBox1.DataSource = MyDataSet
ComboBox1.DisplayMember = "MyTable.MyDescription"
ComboBox1.ValueMember = "MyTable.MyID"
End Sub
T.I.Rislaa