I’m creating a control, and adding a property (control’s look depends on it). How can I set this property:
-
I can’t set the property in form constructor immediatly after
InitializeComponent()call. In this case user will see two frames of form initialization: the first — afterInitializeComponent(), and the second — after property setting, that invoke control’s redrawing. Bad. -
Also, I can’t mark my propperty with BrowsableAttribute, cause a type of the property, is my own class, that can’t be configurated in «properties window». Аlso bad.
So, how could I inicialize the property between form1.SuspendLayout() and form1.ResumeLayout(false)?
Ideally, I would like to have possibility to write a code directly in a respective field of «properties window». For example I would write new MyClass(param1, param2), if type of the property is MyClass.
Don’t force the controll to redraw on property change. It’s not necessary when you initialize the control and when a user change the property it will be redrawn in the next paint event. If needed the user can call .Refresh() on your control after setting the property to force the redraw manually.