答案 0 :(得分:-1)
循环在一段时间内不能一次显示一个循环。将立即执行循环,因此用户只能看到您显示的最后一个循环。如果您想显示一个特定的GroupBox
,那么您可以调用以下方法并传递GroupBox
:
Private Sub ShowGroupBox(groupBoxToShow As GroupBox)
Dim groupBoxes = Me.Controls.OfType(Of GroupBox)()
For Each gb In groupBoxes
gb.Visible = gb Is groupBoxToShow
Next
End Sub
为了在每段时间内显示每个GroupBox
,您应该使用Timer
。每次Timer
引发其Tick
事件时,您都可以显示下一个GroupBox
。
Private groupBoxIndex As Integer = 0
Private Sub Timer1_Tick(...) Handles Timer1.Tick
ShowGroupBox(groupBoxIndex)
groupBoxIndex += 1
End Sub
Private Sub ShowGroupBox(groupBoxIndexToShow As Integer)
Dim groupBoxes = Me.Controls.OfType(Of GroupBox)().ToArray()
If groupBoxIndexToShow = groupBoxes.Length Then
Timer1.Stop()
Else
For i = 0 To groupBoxes.GetUpperBound(0)
groupBoxes(i).Visible = (i = groupBoxIndexToShow)
Next
End If
End Sub