Handling all textbox event in one Handler

后端 未结 4 1906
感动是毒
感动是毒 2020-12-18 11:27

I do know how to handle event of textboxes in my form. But want to make this code shorter because I will 30 textboxes. It\'s inefficient to use this:

Private         


        
4条回答
  •  -上瘾入骨i
    2020-12-18 11:46

    If you have created very Textbox with the Designer, I don't think there is a better method.

    But, if you have created the Textboxes dynamically, you should AddHandler in this way:

    For i = 0 to 30
        Dim TB as New Texbox
        AddHandler TB.TextChanged, TextBox1_TextChanged
        'Set every Property that you need
        Me.Controls.Add(TB)
    Next
    

提交回复
热议问题