Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Overiding functions
Message
De
19/05/2004 17:33:30
 
 
À
19/05/2004 17:27:14
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00905400
Message ID:
00905430
Vues:
9
Jim,

>In order for this to be an event I have to raise an existing event. There isn't one on the grid that suites what I want to do, unless I can define a new event and when it fires. Is that possible?

Yes, this is what I was getting at, defining your own event on your control. Here's what you need to know (this is existing example I have for explaining this, so you can change the MyClick event to something more appropriate for your situation):

In your UserControl, you need the following things:
// First you must make a public EventHandler:
public event EventHandler MyClick;

// Then, when you need to fire the event in your UserControl, do this:
this.OnMyClick(new EventArgs());

// Lastly, this raises the MyClick event:
protected virtual void OnMyClick(EventArgs e)
{
	if (MyClick != null)
		MyClick(this, e);
}
Then, in your form, you just set up the usual delegates and EventHandlers:
this.oMyControl.MyClick += new System.EventHandler(this.oMyControl_MyClickHandler);

private void oMyControl_MyClickHandler(object sender, System.EventArgs e)
{
	// whatever your code needs to be
}
HTH,
~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform