Well, the quick answer is yes. Put the gut methods in your own method, and then just call the onclick event call. This will give you only one place to update the code if you need to change it.
There are 100 different ways to do this, and this is easiest.
So create something like this:
protected void MyNewMethod() { string abc = "123"; }
and then your other methods will simply call it like this:
private void dgv_CellEnter(object sender, DataGridViewCellEventArgs e) { MyNewMethod(); } private void dgv_CellClick(object sender, DataGridViewCellEventArgs e) { MyNewMethod(); }
Option 2
Just call the same method from the markup. You really only need one of these methods, and the event in the markup can cause the same thing.
source share