因此,我能够使用正确的“clientLocations”列表填充组合框。
但是它们的 valueMember 都为 0;因此,手头的问题是将组合框项目的值正确分配给数据库列(在数据集中返回),而不仅仅是名称。
Private Sub updateClientLocationComboBox()
'clear list
comboBox_clientLocations_deviceList.Items.Clear()
'get dataset from database
Dim ds As DataSet = GetClientLocations(_objHost, CInt(comboBox_clients.SelectedValue))
'force insert an "All Locations" datarow
Dim allClientRow As DataRow = ds.Tables(0).NewRow
allClientRow(0) = 0
allClientRow(1) = "--All Locations--"
ds.Tables(0).Rows.InsertAt(allClientRow, 0)
'Check for table in dataset; if exist loop and populate comboBox
If Not ds Is Nothing AndAlso ds.Tables.Count > 0 Then
For Each A As DataRow In ds.Tables(0).Rows
comboBox_clientLocations_deviceList.Items.Add(A("Name").ToString)
Next
End If
End Sub