Skip to main content
gamedev.net
🔒 Locked

[.net] forms: control init

Started by Quat 2 replies 900+ views
Original Post
Quat
Quat
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?
-----Quat
alex_myrpg
alex_myrpg
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.
TheTroll
TheTroll
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
Fiddler
Fiddler
Do you need the control handle for the initialization to work? If yes, override OnHandleCreated. Otherwise, TheTroll's suggestion should work (OnCreateControl).
[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.