是否有内置的 TypeConverter 或 UITypeEditor 来编辑字符串列表
我想知道.Net-3.5是否带有内置的 List
或 string[]
TypeConverter
或 UITypeEditor
这样我就可以从属性网格编辑此类属性。
I wish to know if .Net-3.5 comes with a built-in List<string>
or string[]
TypeConverter
or UITypeEditor
so that I can edit this kind of property from a property grid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于
List
的 UITypeEditor对于
string[]
,您不需要执行任何特殊操作,属性网格将使用包含多行文本框的标准对话框来编辑字符串数组,每一行都是数组中的一个元素。要在属性网格中编辑
List
,您可以使用以下任一选项:StringCollectionEditor
,它显示一个包含多行文本框的对话框,用于编辑CollectionEditor
以编辑集合编辑器对话框中的项目选项 1 - StringCollectionEditor
选项 2 - 自定义 CollectionEditor
首先创建自定义编辑器:
然后使用编辑器属性装饰该属性:
UITypeEditor for
List<String>
For
string[]
you don't need to do anything special and the property grid will use a standard dialog containing a multi-line text box to edit string array and each line will be an element in the array.To edit
List<string>
in property grid, you can use either of the following options:StringCollectionEditor
which shows a dialog containing a multi-line text box to edit elementsCollectionEditor
to edit items in a collection editor dialogOption 1 - StringCollectionEditor
Option 2 - Custom CollectionEditor
First create the custom editor:
Then decorate the property with the editor attribute:
您可以使用 [Editor("System.Windows.Forms.Design.StringArrayEditor, System.Design, [此处的程序集版本和公钥令牌信息]", typeof(System.Drawing.Design.UITypeEditor))]
You can use [Editor("System.Windows.Forms.Design.StringArrayEditor, System.Design, [assembly version and public key token information here]", typeof(System.Drawing.Design.UITypeEditor))]