在vb中为标签数组添加处理程序

时间:2016-12-23 23:07:40

标签: vb.net

你好每个人都希望你很快回答这个问题,我试图在我的标签数组中添加一个处理程序,所以当我双击任何数组时会出现一个msgbox,这里是代码:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    count = 0
    labels()
    DateTimePicker1.Visible = False
    For Each Label In labelarray
        AddHandler Label.DoubleClick, AddressOf label_click

    Next
End Sub
Private Sub label_click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    Dim clickedLabel As Label = DirectCast(sender, Label)
    MessageBox.Show("Label text Clicked was: " & clickedLabel.Text)
End Sub

然后它一直告诉我System.NullReferenceException和标签没什么请求帮助

0 个答案:

没有答案