我一直在做一个 VB 项目,我使用第一个下拉列表选择电影类别,然后在第二个下拉菜单中,将显示该类别的电影。电影按类别存储在二维数组中。
在人们的帮助下,我已经能够编辑我的数组,但是我的 .AddRange() 函数出现了问题。在选择类别时,我将在列表中放入那些括号(对于每个类别)出现在我的第二组合框中的括号?
我试过:
- .AddRange (movie_list_combobox)
- .AddRange (movie_category_combobox)
- .AddRange (Array(movie_list_combobox))
- .AddRange (Array(movie_category_combobox))
没有任何效果。
更改的项目:
- 更新数组
- 我没有使用 if/else 语句,而是使用 for/next(也不再使用 Select Case)
- 添加了 addRange()
我在下面附上了我的代码:
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
请让我知道我的代码的哪些部分是错误的。