[Mono-winforms-list] Using PropertyGrid with UITypeEditor

Mike Deskevich mikedeskevich at gmail.com
Sun Jun 24 15:02:14 EDT 2007


I'm having a problem that I can't seem to figure out.  I created a
class that has a public property with an array of enums.  I would like
to have an Editor that allows the user select 0 or more enums to
populate this array.  My problem is that the PropertyGrid won't
display either the elipses or the dropdown button for me.

Below is an example of the how I have the classes set up.  When i
create a PropertyGrid and set the SelectedObject to an instance of
ClassToEdit all the properties show up how they're supposed to except
for the array of MyEnum.

Any hints?  I've looked through the MSDN and it looks like I'm
implementing this just like all of the examples.

public class ClassToEdit
{
   //didn't copy the other simple properties here

   //here's my custom type
   MyEnum[] m_enums;
   [Editor(typeof(MyEnumArrayEditor),typeof(UITypeEditor))]
   property MyEnum[] enums
   {
      get
      {
         return m_enums;
       }
       set
       {
          m_enums=value;
       }
   }
}

public class MyEnumArrayEdior : UITypeEditor
  {
    private IWindowsFormsEditorService edSvc;
		
    public override UITypeEditorEditStyle
GetEditStyle(ITypeDescriptorContext context)
    {
       return UITypeEditorEditStyle.DropDown;
    }

    public override Object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, Object value)
    {
        //populate the combo box and stuff here
    }
  }


More information about the Mono-winforms-list mailing list