PropertyGrid 控件的默认内置编辑器

发布于 2024-07-17 18:38:54 字数 212 浏览 5 评论 0原文

我似乎无法在任何地方找到这个问题的答案。 3.5 Framework PropertyGrid 控件中内置了哪些默认编辑器/转换器。 否则我可以向它扔什么对象类型并且它能够可靠地显示和编辑? 我发现了很多有关使用自定义编辑器的教程(我可能会在某个时候这样做)。 但现在在我的程序中,我允许用户创建自己的自定义属性,并且我想知道假设他们将在 PropertyGrid 中编辑它们,我应该允许哪些对象类型。

I can't seem to find the answer to this anywhere. What default editors/converters are building into 3.5 Framework PropertyGrid control. Otherwise what object types can I throw at it and it be able to reliably show and edit? I've found a lot of tutorials on using custom editors (which I may do at some point). But right now in my program I'm allowing the user to create their own custom properties and I want to know what object types I should allow assuming they will be editing them in a PropertyGrid.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

独自←快乐 2024-07-24 18:38:54

请记住,有一些非公开课程。

System.Object
  System.Drawing.Design.UITypeEditor
    System.ComponentModel.Design.CollectionEditor
      System.ComponentModel.Design.ArrayEditor
      System.Web.UI.Design.CollectionEditorBase
      System.Web.UI.Design.WebControls.WizardStepCollectionEditor
      System.Web.UI.Design.WebControls.EmbeddedMailObjectCollectionEditor
      System.Web.UI.Design.WebControls.HotSpotCollectionEditor
      System.Web.UI.Design.WebControls.ListItemsCollectionEditor
      System.Web.UI.Design.WebControls.MenuItemStyleCollectionEditor
      System.Web.UI.Design.WebControls.RoleGroupCollectionEditor
      System.Web.UI.Design.WebControls.StyleCollectionEditor
      System.Web.UI.Design.WebControls.SubMenuStyleCollectionEditor
      System.Web.UI.Design.WebControls.TableCellsCollectionEditor
      System.Web.UI.Design.WebControls.TableRowsCollectionEditor
    System.ComponentModel.Design.BinaryEditor
    System.ComponentModel.Design.DateTimeEditor
    System.ComponentModel.Design.MultilineStringEditor
    System.ComponentModel.Design.ObjectSelectorEditor
    System.Windows.Forms.Design.AnchorEditor
    System.Windows.Forms.Design.BorderSidesEditor
    System.Windows.Forms.Design.DockEditor
    System.Windows.Forms.Design.FileNameEditor
    System.Windows.Forms.Design.FolderNameEditor
    System.Windows.Forms.Design.ShortcutKeysEditor
    System.Web.UI.Design.ConnectionStringEditor
    System.Web.UI.Design.DataBindingCollectionEditor
    System.Web.UI.Design.ExpressionsCollectionEditor
    System.Web.UI.Design.UrlEditor
    System.Web.UI.Design.XmlFileEditor
    System.Web.UI.Design.WebControls.DataGridColumnCollectionEditor
    System.Web.UI.Design.WebControls.DataControlFieldTypeEditor
    System.Web.UI.Design.WebControls.MenuBindingsEditor
    System.Web.UI.Design.WebControls.MenuItemCollectionEditor
    System.Web.UI.Design.WebControls.ParameterCollectionEditor
    System.Web.UI.Design.WebControls.RegexTypeEditor
    System.Web.UI.Design.WebControls.TreeNodeCollectionEditor
    System.Web.UI.Design.WebControls.TreeViewBindingsEditor
    System.Web.UI.Design.WebControls.DataPagerFieldTypeEditor
    System.Messaging.Design.QueuePathEditor
    System.Drawing.Design.ImageEditor
    System.Drawing.Design.ColorEditor
    System.Drawing.Design.ContentAlignmentEditor
    System.Drawing.Design.CursorEditor
    System.Drawing.Design.FontEditor
    System.Drawing.Design.FontNameEditor
    System.Drawing.Design.IconEditor
    System.Workflow.ComponentModel.Design.TypeBrowserEditor
    System.Workflow.ComponentModel.Design.BindUITypeEditor

Bear in mind that there some non-public classes.

System.Object
  System.Drawing.Design.UITypeEditor
    System.ComponentModel.Design.CollectionEditor
      System.ComponentModel.Design.ArrayEditor
      System.Web.UI.Design.CollectionEditorBase
      System.Web.UI.Design.WebControls.WizardStepCollectionEditor
      System.Web.UI.Design.WebControls.EmbeddedMailObjectCollectionEditor
      System.Web.UI.Design.WebControls.HotSpotCollectionEditor
      System.Web.UI.Design.WebControls.ListItemsCollectionEditor
      System.Web.UI.Design.WebControls.MenuItemStyleCollectionEditor
      System.Web.UI.Design.WebControls.RoleGroupCollectionEditor
      System.Web.UI.Design.WebControls.StyleCollectionEditor
      System.Web.UI.Design.WebControls.SubMenuStyleCollectionEditor
      System.Web.UI.Design.WebControls.TableCellsCollectionEditor
      System.Web.UI.Design.WebControls.TableRowsCollectionEditor
    System.ComponentModel.Design.BinaryEditor
    System.ComponentModel.Design.DateTimeEditor
    System.ComponentModel.Design.MultilineStringEditor
    System.ComponentModel.Design.ObjectSelectorEditor
    System.Windows.Forms.Design.AnchorEditor
    System.Windows.Forms.Design.BorderSidesEditor
    System.Windows.Forms.Design.DockEditor
    System.Windows.Forms.Design.FileNameEditor
    System.Windows.Forms.Design.FolderNameEditor
    System.Windows.Forms.Design.ShortcutKeysEditor
    System.Web.UI.Design.ConnectionStringEditor
    System.Web.UI.Design.DataBindingCollectionEditor
    System.Web.UI.Design.ExpressionsCollectionEditor
    System.Web.UI.Design.UrlEditor
    System.Web.UI.Design.XmlFileEditor
    System.Web.UI.Design.WebControls.DataGridColumnCollectionEditor
    System.Web.UI.Design.WebControls.DataControlFieldTypeEditor
    System.Web.UI.Design.WebControls.MenuBindingsEditor
    System.Web.UI.Design.WebControls.MenuItemCollectionEditor
    System.Web.UI.Design.WebControls.ParameterCollectionEditor
    System.Web.UI.Design.WebControls.RegexTypeEditor
    System.Web.UI.Design.WebControls.TreeNodeCollectionEditor
    System.Web.UI.Design.WebControls.TreeViewBindingsEditor
    System.Web.UI.Design.WebControls.DataPagerFieldTypeEditor
    System.Messaging.Design.QueuePathEditor
    System.Drawing.Design.ImageEditor
    System.Drawing.Design.ColorEditor
    System.Drawing.Design.ContentAlignmentEditor
    System.Drawing.Design.CursorEditor
    System.Drawing.Design.FontEditor
    System.Drawing.Design.FontNameEditor
    System.Drawing.Design.IconEditor
    System.Workflow.ComponentModel.Design.TypeBrowserEditor
    System.Workflow.ComponentModel.Design.BindUITypeEditor
原谅过去的我 2024-07-24 18:38:54

您可能想查看派生自 的类UITypeEditor(在 System.Drawing.Design 命名空间)。 这些类型将作为参数传递给 EditorAttribute< /code>(在 System.ComponentModel命名空间)。

您还可以查看该类型的元数据,以了解 EditorAttribute 的应用位置。 但是,不要在这里使用反射,因为这不是PropertyGrid 使用。

而是使用 TypeDescriptor 类 获取类型属性的属性描述符(调用静态 GetProperties 方法)。 然后,使用 PropertyDescriptor 实例,调用 GetEditor 方法获取该属性的编辑器实例。

You might want to take a look at classes that derive from UITypeEditor (in the System.Drawing.Design namespace). These types will be passed as parameters to the EditorAttribute (in the System.ComponentModel namespace).

You can also look at the metadata for the type to see where the EditorAttribute is applied. However, do not use reflection here, as that is not what the PropertyGrid class uses.

Rather use the TypeDescriptor class to get property descriptors for the properties on the type (call the static GetProperties method). Then, with the PropertyDescriptor instance, call the GetEditor method to get an instance of the editor for that property.

戏蝶舞 2024-07-24 18:38:54

实际上,您可以将任何对象扔到 PropertyGrid 上。 它会自动做很多事情。 如果您想获得原生不提供的特殊编辑体验,则只需创建自定义 UI 类型编辑器。 即使在这种情况下,您也可以针对每个属性执行此操作,而不是针对整个对象。

You can actually throw any object at the PropertyGrid. It will do a lot of things automatically. You only need to create custom UI type editors if you want to have a special edit experience, which is not natively provided. And even in that case you do it per property and not for a whole object.

零崎曲识 2024-07-24 18:38:54

PropertyGrid 使用 TypeConverters,并且每个基本类型(以及基本类型的集合)都有 TypeConverters。

只要您使用一种基本类型或一组基本类型,属性网格就应该能够提供编辑 UI。

The PropertyGrid uses TypeConverters and there are TypeConverters for every primitive type (as well as collections of primitive types).

As long as you're using one of the primitive types or a collection of primitive types the property grid should be able to take care of providing an editing UI.

若沐 2024-07-24 18:38:54

除了 UITypeEditors 之外,PropertyGrid 还能够显示具有 CanConvertFrom(String) 返回 true 的 TypeConverter 的任何对象。 您可以为特定对象类型实现自己的 TypeConverters 以实现此目的。

Besides UITypeEditors, the PropertyGrid is able to display any object with a TypeConverter that returns true for CanConvertFrom(String). You can implement your own TypeConverters for specific object types in order to accomplish this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文