Allow multi-line String properties in the Properties window

梦想的初衷 提交于 2019-11-28 11:20:15
manji

You can use the EditorAttribute with a MultilineStringEditor:

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

To avoid adding a reference to System.Design and thus requiring the Full framework, you can also write the attribute like this:

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

Although this is less of a problem now that they've stopped splitting the framework into a Client Profile and a Full one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!