Jump to content
  • Advertisement
Sign in to follow this  
v0dKA

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

This topic is 4421 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
in the forms constructor, after "InitializeComponents()" or what ever that line is called?
or in FormName_Load() (wich gets raised on form load..)

Share this post


Link to post
Share on other sites
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!