是否可以使用不同的事件调用另一个私有子?

时间:2017-06-14 01:22:40

标签: vb.net winforms

有可能吗?例如,

Private Sub inputno_tb_MouseDown(sender As Object, e As MouseEventArgs)
     'My code
End Sub

Private Sub stacker1apcs_tb_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs)
     'Calling Private Sub inputno_tb_MouseDown
End Sub

1 个答案:

答案 0 :(得分:0)

当然可以这样做:

Private Sub inputno_tb_MouseDown(sender As Object, e As MouseEventArgs)
    'My code
End Sub

Private Sub stacker1apcs_tb_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs)
    inputno_tb_MouseDown(sender, MouseEventArgs.Empty)
End Sub

如果您在代码中使用sender,则可能需要将其更新为stacker1apcs_tb,或者您喜欢的任何内容。