General information
Title:
Calling a event handler from another event?
I have code in an event handler that I want to use by various events, but I seem to have an overlay mismatch problem...
The object is a DataGridView, and the working code is presently in the form.CellClick() event handler, like this:
private void mmGridCustomers_CellClick(object sender, DataGridViewCellEventArgs e)
{
string CustNo = this.mmGridCustomers.GetCurrentRowPK().ToString();
this.Job.GetJobsByCustNo(CustNo);
}
Now, I want to activate this same event handler code with another event of the grid, which is the RowHeaderMouseClick() event. In other words, I want the same thing to happen with each of these two possible user actions.
In the Poperties page of the form designer IDE, when trying to assign the existing event handler to the RowHeaderMouseClick(), I noticed that the existing event handler does not appear in the dropdown list to choose from, and I guess I have figured out that it is becuase the two events have different "signatures" (is that how you say it?) because they have different parameters or overloads?
So, I am presently doing this trick of just passing null values to the target event handler, since the parameters are not used in the method code anyway:
private void mmGridCustomers_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
this.mmGridCustomers_CellClick(null,null);
}
It works, but is this a good practice, or is there a better or more proper way to handle this?
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only