Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Events 1

Status
Not open for further replies.

seanbo

Programmer
Jun 6, 2003
407
GB
i know how to make use of events. i use events like 'paint' and 'onClick' all the time, as you could imagine. but how do i create my own? i want to trigger an event when ever the renderer i'm writing has completed another object.
 
I'm a bit of an inexperienced programmer myself, so I'm slightly cautious about making a suggestion, but I thought I might as well try to help...

If the renderer you're working with is a user control then making your own custom events isn't too complicated. Add a property to the form that looks like this.

public event EventHandler YourEventName;

Whenever you want that event to occur, the line

YourEventName(this, new EventArgs());

will raise the event. One more helpful tidbit is that I usually structure a raised event like so

if (YourEventName != null)
YourEventName(this, new EventArgs());


The reason I check for null is if I raise the event while the control is loading an error occurs.

I hope all of that helps.

-Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top