What's the simplest .NET equivalent of a VB6 control array?

后端 未结 9 1714
时光取名叫无心
时光取名叫无心 2020-12-11 03:42

Maybe I just don\'t know .NET well enough yet, but I have yet to see a satisfactory way to implement this simple VB6 code easily in .NET (assume this code is on a form with

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 04:10

    The same click event can handle the button presses from multiple buttons in .Net. You could then add the the text box to find in the Tag property?

    Private Sub AllButton_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
      Dim c As Control = CType(sender, Control)
      Dim t As TextBox = FindControl(CType(c.Tag, String))
      If t Is Not Nothing Then
         t.Text = "Clicked"
      End If
    End Sub
    

提交回复
热议问题