更新时间:2023-10-29 16:20:10
不要这样做!
如果代码的某些部分应该在两个事件中都有效:Button_Click
事件和DataGridView_CellClick
,移动它进入另一个函数/程序。
Don''t do that!
If some part of code should work in both events:Button_Click
event andDataGridView_CellClick
, move it into another function/procedure.
Private Sub DoSomething(CurrentDGVCell As Integer)
'here your code
End Sub
然后这样打电话:
then call like this:
Private Sub ContextGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ContextGridView.CellClick
DoSomething(GetCurrentDGVCell)
End Sub
Public Sub bt_CreateName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_CreateName.Click
DoSomething(GetCurrentDGVCell)
End sub