1

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.

?

Blam
  • 2,888
  • 3
  • 25
  • 39
  • Duplicate of http://stackoverflow.com/questions/130032/multi-line-string-in-a-propertygrid – Larry Nov 09 '10 at 09:48

2 Answers2

6

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;
}
Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
1

This happens through a "designer". For System.Windows.Forms.TextBox that designer is:

[Designer("System.Windows.Forms.Design.TextBoxDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), SRDescription("DescriptionTextBox"), ComVisible(true), ClassInterface(ClassInterfaceType.AutoDispatch)]

If you want to view its source code, open up .NET Reflector, Open Cache... System.Design, navigate (or search) to System.Windows.Forms.Design.TextBoxDesigner.

UPDATE: Since 2014, the .NET Core is open-source, check out the official repository site

Tergiver
  • 14,171
  • 3
  • 41
  • 68