N
Nathan
I have a form with two cboboxes with the DropDownStyle set to DropDown.
When the form loads, it fills cboCategory1 with data. When the text of
cboCategory1 changes (when an item in the list is selected or a new entry is
made), cboCategory2 is supposed to fill with relevant categories:
\\\
Private Sub cboCategory1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboCategory1.TextChanged
Dim a As Integer
MsgBox("")
cboCategory2.Items.Clear()
For a = 0 To Category2.GetUpperBound(0) 'Category2 is a DataRow with
columns "Category1" and "Category2"
If Category2(a)("Category1").ToString = cboCategory1.SelectedText Then
If Not cboCategory2.Items.Contains(Category2(a)("Category2").ToString)
Then
cboCategory2.Items.Add(Category2(a)("Category2").ToString)
End If
End If
Next
End Sub
\\\
Now you're first question is going to be, what's the purpose of MsgBox("")?
I put that in at first to test whether the .TextChanged event was being
called properly. The strange thing is, the code as it is above works, but
if I take MsgBox("") out, it doesn't. I tried taking it out, closing VS,
restarting the computer and reloading the solution. It still didn't work
unless I put the MsgBox("") back in. What is happening?
When the form loads, it fills cboCategory1 with data. When the text of
cboCategory1 changes (when an item in the list is selected or a new entry is
made), cboCategory2 is supposed to fill with relevant categories:
\\\
Private Sub cboCategory1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboCategory1.TextChanged
Dim a As Integer
MsgBox("")
cboCategory2.Items.Clear()
For a = 0 To Category2.GetUpperBound(0) 'Category2 is a DataRow with
columns "Category1" and "Category2"
If Category2(a)("Category1").ToString = cboCategory1.SelectedText Then
If Not cboCategory2.Items.Contains(Category2(a)("Category2").ToString)
Then
cboCategory2.Items.Add(Category2(a)("Category2").ToString)
End If
End If
Next
End Sub
\\\
Now you're first question is going to be, what's the purpose of MsgBox("")?
I put that in at first to test whether the .TextChanged event was being
called properly. The strange thing is, the code as it is above works, but
if I take MsgBox("") out, it doesn't. I tried taking it out, closing VS,
restarting the computer and reloading the solution. It still didn't work
unless I put the MsgBox("") back in. What is happening?