Default built-in editors for the PropertyGrid control
Asked Answered
B

5

13

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.

Beret answered 9/4, 2009 at 19:37 Comment(1)
I'm still hoping to find a project that lists the various UITypeEditors as others have linked to here, but also show exactly what Types use each editor, and a preview of what they look like.Northamptonshire
T
6

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.

Tensible answered 9/4, 2009 at 19:47 Comment(0)
R
8

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
Randell answered 23/2, 2010 at 12:25 Comment(0)
T
6

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.

Tensible answered 9/4, 2009 at 19:47 Comment(0)
E
1

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.

Epiphytotic answered 9/4, 2009 at 19:40 Comment(2)
But what are all the things it will do automaticly? Right now I don't want to deal with custom editors. I've tried various numbers, string, bool, and DateTime and they all either work or have built in editors. I was hoping there was a list somewhere of all the types that can be edited by default.Beret
You can look at the inheritance hierarchy of your property types if they have a UITypeEditor attached as an attribute or not. By default the property grid needs either an editor or a type converter to get to/from string.Epiphytotic
P
1

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.

Pyrite answered 9/4, 2009 at 19:55 Comment(0)
T
1

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.

Twinberry answered 14/9, 2009 at 15:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.