Hi, Hashcode!

I create a control, inheriting from UserControl . To it I add the property on which the appearance of the control depends.

Now attention, if you assign this property in the code of the form designer immediately after InitializeComponent() , then first the user will see the form as it looked in my “mouse design” mode, and after that the control will be re-generated into the desired form. Poorly.

I also cannot mark a property with the help of BrowsableAttribute , because the type of property is my own class, which the environment cannot configure. Poorly.

How to make property initialization happen between the first form1.SuspendLayout() and form1.ResumeLayout(false)?


Ideally, I would like to be able to write code directly in the fields of the "properties" window. For example, if a property has the type MyClass , then I would write new MyClass(param1, param2) in the appropriate field from the “properties” window.

    1 answer 1

    In .Net it is possible to create your own property control editors based on UITypeEditor , which will just give you the opportunity to change the control property through its user interface.

    Related Links:

    Class UITypeEditor

    Article: Creating Custom Controls - Providing Design Time Support

    Walkthrough. Implementing the user interface type editor