gchq
Well-known member
- Joined
- Dec 14, 2007
- Messages
- 168
- Programming Experience
- 10+
Hi there
In a combobox populated by a DataTable I am having two issues!
The SelectedIndex property will not set
1. Either by integer
2. Or by FindString
If I attempt to set the index (SupplyTypeList.SelectedIndex = 1) it blows out with InvalidArgument
If I attempt set the index via the FindString method it always returns a value of -1
.. even though the string is valid and is in the ComboBox!
Any ideas?
Thanks
In a combobox populated by a DataTable I am having two issues!
The SelectedIndex property will not set
1. Either by integer
2. Or by FindString
VB.NET:
Dim SupplyTypeList As New ComboBox
SupplyTypeList.Name = "SupplyTypeList"
SupplyTypeList.Location = New Point(220, 10)
Dim vList As New DataTable
vList.Columns.Add("ID", GetType(Integer))
vList.Columns.Add("String", GetType(String))
Dim vRow As DataRow = vList.NewRow
vRow("ID") = 0
vRow("string") = "Select Type"
vList.Rows.Add(vRow)
vRow = vList.NewRow
vRow("ID") = 1
vRow("String") = "Stock Item"
vList.Rows.Add(vRow)
vRow = vList.NewRow
vRow("ID") = 2
vRow("String") = "Reserve Item"
vList.Rows.Add(vRow)
SupplyTypeList.DataSource = vList
SupplyTypeList.DisplayMember = "String"
SupplyTypeList.ValueMember = "ID"
If I attempt to set the index (SupplyTypeList.SelectedIndex = 1) it blows out with InvalidArgument
If I attempt set the index via the FindString method it always returns a value of -1
VB.NET:
Dim vListRows() As DataRow = vList.Select("ID = " & row("Supply_Type"))
SupplyTypeList.SelectedIndex = SupplyTypeList.FindString(vListRows(0)("String"))
.. even though the string is valid and is in the ComboBox!
Any ideas?
Thanks