我想更改布尔列表的内容,所以我通过引用将它传递给方法,如下所示:
Dim liste As New List(Of Boolean)
liste.Add(lbl1.Visible)
liste.Add(lbl2.Visible)
RaiseEvent rgProcS9Selection(liste, SelectedIndex)
方法中的:
Private Sub rgProcS9SelectionMethod(ByRef ComposantsVisibility As List(Of Boolean), ByVal SelectedIndex As Integer)
ComposantsVisibility.Clear()
If SelectedIndex = 0 Then
For index As Integer = 0 To 1
ComposantsVisibility.Add(False)
Next
Else
For index As Integer = 0 To 11
ComposantsVisibility.Add(True)
Next
End IF
End Sub
列表的内容值已更改,但标签的可见性(lbl1,lbl2)仍然相同。
答案 0 :(得分:1)
您需要two
个列表。一个用于可见性,一个用于标签:
Dim liste As New List(Of Boolean)
Dim listeL As New List(Of Label)
liste.Add(lbl1.Visible)
liste.Add(lbl2.Visible)
listeL.Add(lbl1)
listeL.Add(lbl2)
RaiseEvent rgProcS9Selection(liste, listeL, SelectedIndex)
并在rgProcS9SelectionMethod
:
Private Sub rgProcS9SelectionMethod(ByVal ComposantsVisibility As List(Of Boolean), ByVal ComposantsLabels As List(Of Label), ByVal SelectedIndex As Integer)
...
...
For i = 0 To ComposantsLabels.Count - 1
ComposantsLabels(i).Visible = ComposantsVisibility(i)
Next
End Sub