Search code examples
c#custom-controlspropertygrid

Making a custom control's property input like that of a multiline textbox


Say I have attribute "Address", how can I make it's input in the form designer's property box like that of a text box's text input, like so:

Textbox input image.

?


Solution

  • Decorate your Address property with an EditorAttribute referencing the MultilineStringEditor class:

    using System.ComponentModel;
    using System.Drawing.Design;
    
    [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
        typeof(UITypeEditor))]
    public string Address
    {
        get;
        set;
    }