VB.NET:如何以编程方式向WinForm添加多个控件

时间:2013-11-24 12:54:59

标签: vb.net winforms controls

我正在尝试在计时器刻度事件中为表单添加标签。它添加第一个标签没问题,但似乎不再添加。

经过一些调试后,我可以看到控件已添加,但它只显示第一个标签。这里有什么我想念的吗?

Private Sub timTick1_Tick(sender As System.Object, e As System.EventArgs) Handles timTick1.Tick
    iTick1 += 1
    lblTick1.Text = iTick1

    iPhase += 1
    lblPhase.Text = iPhase

    Select Case iPhase
        Case 1
            Phase1()
        Case 2
            Phase2()
        Case 3
            Phase3()
        Case 4
            Phase4()
    End Select

    If iPhase = 4 Then
        iPhase = 0
    End If
End Sub

Private Sub Phase4()
    Panel3.Controls.Add(New Label With {.Text = "TESTING" & iTick1, .Location = New Point(iTick1, iTick1)})
End Sub

0 个答案:

没有答案
相关问题