我在FormStart上有用户控件NumericKeyPad,我需要,当我点击按钮时,例如Formstart textBoxEmployee上的button3(标签值为3)#它写3等等......
答案 0 :(得分:0)
在UserControl
中创建一个自定义事件,单击句柄按钮并从那里提起它。然后,从父表单处理UserControl
的自定义事件。为了说明,这里是一个代码示例(VB.NET - 我不是很擅长C#):
Public Class UserControl1
Public Event ButtonClicked(tag As Object)
Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
RaiseEvent ButtonClicked(CType(sender, Button).Tag)
End Sub
End Class
Public Class Form1
Private Sub UserControl11_ButtonClicked(tag As Object) Handles UserControl11.ButtonClicked
TextBox1.Text = tag
End Sub
End Class