如何创建“可用字段"?我自己的财产中的财产? [英] How to create "Available field" properties in my own property?

查看:88
本文介绍了如何创建“可用字段"?我自己的财产中的财产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个从StateManagedCollection继承的类.它有一些像GridView这样的列.但是我无法选择要从中选择的文件.它的外观应如下图所示.

I have created a class inherit from StateManagedCollection. It has got a few class as Columns like GridView. But I can not select which filed I want to select from. It should look like the picture below in design.

但是我的是下面的一个:

But mine is the one below:

我写的属性如下:

[Description("A collection of ToolBarItem's ")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(typeof(System.ComponentModel.Design.CollectionEditor), typeof(System.Drawing.Design.UITypeEditor)), PersistenceMode(PersistenceMode.InnerProperty)]
public virtual Items Items
{
}

有人可以帮我吗?

推荐答案

GridView列集合使用自定义UI类型编辑器来显示此界面.内置的ASP.NET CollectionEditor 将不会显示所需的UI.此外,对于您来说,如果集合的项目类型是抽象类,则 CollectionEditor 可能不起作用.

GridView columns collection uses a custom UI Type editor to show this interface. The in-built ASP.NET CollectionEditor will not show the required UI. Further in your case, CollectionEditor may not work if the collection's item type is a abstract class.

解决方案是构建自己的自定义 UI类型编辑器-基本步骤是

Solution is to build your own custom UI Type editor - basic steps are

  1. 继承自 System.Drawing.Design.UITypeEditor .
  2. 重写 GetEditStyle 方法以通知属性浏览器您将启动模式表单.
  3. 重写EditValue方法以启动您的自定义UI表单.
  4. 构建自定义UI表单.
  1. Inherit from System.Drawing.Design.UITypeEditor.
  2. Override GetEditStyle method to inform the property browser that you will launch modal form.
  3. Override the EditValue method to launch your custom UI form.
  4. Build the custom UI Form.

请参见此处(参见示例)用于TagTypeEditor)和此处.

See a couple examples here (see sample for TagTypeEditor) and here.

这篇关于如何创建“可用字段"?我自己的财产中的财产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆