I’ve been working on a VB project where I use a 1st drop down list to select a movie category and then in the 2nd drop menu, movies from that category will be displayed. The movies are stored in a 2-dimensional array by category.
With help from folks here, I’ve been able to edit my array but I’m having problems with my .AddRange() function. What would I have to put in those parentheses for the list (for each category) to appear in my 2nd combobox when the category is selected?
I tried:
- .AddRange (movie_list_combobox)
- .AddRange (movie_category_combobox)
- .AddRange (Array(movie_list_combobox))
- .AddRange (Array(movie_category_combobox))
Nothing has worked.
items changed:
- Updated array
- Instead of using if/else statement, I’m using for/next (no longer using Select Case either)
- added addRange()
I’ve attached my code below:
Public Class Video_Form
Private Sub count_textbox_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles count_textbox.TextChanged
End Sub
Private Sub Count_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Count.Click
count_textbox.Text = Me.movie_list_combobox.Items.Count
End Sub
Private Sub movie_categories_combobox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles movie_categories_combobox.SelectedIndexChanged
End Sub
Private Sub movie_list_combobox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movie_list_combobox.SelectedIndexChanged
Dim Movies(,) As String = {{"Meet", "Oxford", "Sterilite"}, {"Sunflower", "Seeds", ""}, {"Black Box", "", ""}, {"Dancing ", "", ""}, {"Dictionary", "", ""}, {"Glue", "Flight", ""}}
Dim row As Integer
Dim column As Integer
For movie_categories_combobox.SelectedIndex = 0 Then
row = 0 To 2
column = 0 To 0
movie_list_combobox.Items.Clear()
movie_list_combobox.Items.AddRange()
Next
For movie_categories_combobox.SelectedIndex = 1 Then
row = 0 To 1
column = 1 To 1
movie_list_combobox.Items.Clear()
movie_list_combobox.Items.AddRange()
Next
For movie_categories_combobox.SelectedIndex = 2 Then
row = 0 To 0
column = 2 To 2
movie_list_combobox.Items.Clear()
movie_list_combobox.Items.AddRange()
Next
For movie_categories_combobox.SelectedIndex = 3 Then
row = 0 To 0
column = 3 To 3
movie_list_combobox.Items.Clear()
movie_list_combobox.Items.AddRange()
Next
For movie_categories_combobox.SelectedIndex = 4 Then
row = 0 To 0
column = 4 To 4
movie_list_combobox.Items.Clear()
movie_list_combobox.Items.AddRange()
Next
For movie_categories_combobox.SelectedIndex = 5 Then
row = 0 To 1
column = 5 To 5
movie_list_combobox.Items.Clear()
movie_list_combobox.Items.AddRange()
Next
'//End If
'//End Select
End Sub
Please let me know what part(s) of my code are wrong.
In my opinion your problem isn’t very clear…btw maybe i can help you by telling you what would i do if i were in you.
I’ll declare a 2 dimension array in this way….for ex. funny films at index 0 and kolossal at index 1….
Then, populate the movie category combobox:
Finally, when the movie_category_combobox.SelectedIndexChanged has thrown, you only need to:
Hope it helps….