Sign in to follow this  
Quat

[.net] forms: control init

Recommended Posts

Quat    568
I have a custom control that needs to do some initialization work. I don't want to put it in the constructor however. Is there an Init method or OnCreate method I can override to put my init code?

Share this post


Link to post
Share on other sites
alex_myrpg    351
Perhaps the OnCreateControl method is what you're looking for? You should be able to override the method in a Control or UserControl based class.

Share this post


Link to post
Share on other sites
TheTroll    883
You can override InitLayout, but that is really for custom layout due to the container holding the control.

I would create a InitControl method with all of the stuff you want to do and then just add a InitControl() call in the constructor.

theTroll

Share this post


Link to post
Share on other sites
Fiddler    860
Do you need the control handle for the initialization to work? If yes, override OnHandleCreated. Otherwise, TheTroll's suggestion should work (OnCreateControl).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this