Jump to content
  • Advertisement
Sign in to follow this  

[C#] What event gets sent when a control is created?

This topic is 4236 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to be able to set some variables when one of the controls in my form gets created. However, I cannot find the name of the event that gets raised in such a case. Is there one?

Share this post


Link to post
Share on other sites
Advertisement
Due to the way events work in .NET, I don't think you can register for an event that belongs to a control before the control even exists.

However, I do believe there is a ControlAdded event for the parent control that has child controls added to it. Perhaps that would suit your needs?

Share this post


Link to post
Share on other sites
Thanks for the help.

I think found a work-around for my specific issue.

By the way, thanks for the link ViLiO. I'm sure I'll find it useful very soon.

And thanks for the alternate solution, Agony. I don't happen to need it this time, but I'll keep it in mind.

Share this post


Link to post
Share on other sites
You can make a static event, which you trigger in the control's contructor. This way, whenever an instance of that control is created, the event is called.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!