Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling a event handler from another event?
Message
De
28/03/2008 16:47:07
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Calling a event handler from another event?
Divers
Thread ID:
01306622
Message ID:
01306622
Vues:
56
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?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform