在“属性”窗口中允许多行String属性

我有一个带有字符串属性的Windows窗体用户控件,用于设置文本框的文本。 这个字符串可以是多行的。

我注意到在一些带有文本属性的控件上,而不是强制键入单行属性文本框,你会弹出一个可以输入多行的地方。 (事实上​​,Windows窗体文本框控件允许在Text属性上使用它。)

如何在我设计的属性的属性窗口中启用此function?

以下不是我的应用程序中的真实代码,而是如何定义此类属性的示例

public string Instructions { get { return TextBox1.Text; } set { TextBox1.Text = value; } } 

您可以将EditorAttributeMultilineStringEditor一起使用:

 [EditorAttribute(typeof(MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))] public string Instructions { get { return TextBox1.Text; } set { TextBox1.Text = value; } } 

为了避免添加对System.Design的引用并因此需要Full框架,您还可以编写如下属性:

 [EditorAttribute( "System.ComponentModel.Design.MultilineStringEditor, System.Design", "System.Drawing.Design.UITypeEditor")] 

虽然现在他们已经停止将框架拆分为客户端配置文件和完整客户端配置文件,但这不是一个问题。