I have two Comboboxes and a DataGridView. the first ComboBox looks at column of the DataGridView for its values. I need the second ComboBox to look at the value of the first and then get the values from the table filtered by the Value of the first ComboBox.
I get the information for the first ComboBox like this: (This runs on the "Form Load" Event)
With FItemTypeComboBox
.DataSource = DbStarFliteSystemsDataset.tblItems
.ValueMember = "fItemType"
End With
For the second ComboBox's Datasource, I want to run a query that functions something like:
SELECT DISTINCT fItemName FROM tblItems
WHERE "fItemType" = FItemTypeComboBox.Text
But I don't know where or how to implement this.
I have tried the following, but no matter what variation I run, it always fails:
Private Sub FItemNameComboBox_Enter(sender As Object, e As EventArgs) Handles FItemNameComboBox.Enter
Dim table As DataTable = New DataTable("tblItems")
table.Columns.Add("fItemType")
table.Columns.Add("fItemName")
Dim Result() As DataRow = table.Select("fItemType" = FItemTypeComboBox.Text)
With FItemNameComboBox
.DataSource = Result
.ValueMember = Result.ToString
End With
End Sub
I am using Visual Studio 2013 and (obviously) Visual Basic.
Dim result As Object = (From row As DataRow In table Where row.Field(Of Integer)("id") = 1 Select row). If I hover the mouse over the first ( inDim result As Object = (...I see that the returned result isEnumerableRowCollection(Of DataRow). - Bjørn-Roger Kringsjå