Question

EnumPropertyEditor and controlling EnumListBoxDisplayMode

Posted 5 months ago by Avatar Wiley Knoch

I am using the EnumPropertyEditor to display some enum values to pick from in a property grid.  It is fantastically designed to support switching between CheckBox & RadioButton display modes based on whether the enum has the Flags attribute implemented.  My issue is that I need to conditionally change the display mode from CheckBox to RadioButton for a enum that has the flags attribute and cannot figure out how to properly do this.

Since I will need to conditionally do this for specific scenarios I created my own custom class that inherits EnumPropertyEditor that I use to control the display mode:

public class MyEnumPropertyEditor : EnumPropertyEditor
{
   public MyEnumPropertyEditor()
   {
      // How do I change the display mode for the EnumListBox that will be created for this editor instance?
      EnumListBoxDisplayMode.RadioButton;
   }
}

[DisplayName("Some Display")]
[Editor(typeof(MyEnumPropertyEditor), typeof(UITypeEditor))]
public EnumWithFlags SomeEnumProperty { get; set; }

Any help in solving this would be appreciated.


Comments (2)

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Wiley,

We're glad you like the EnumEditBox.  Unfortunately there isn't a way to dynamically switch between flags and non-flags modes.  It determines that pretty deeply in the code (in EnumListBox) based on the presence of the Flags attribute.

Is it possible for you to clone the Flags-based enum and name it without the plural enum name, also excluding the Flags attribute on it?  Then you'd have two enums with the same values but one is flags and one is not.  That is effectively what we do in our sample too and works great.


Actipro Software Support
Posted 5 months ago by Wiley Knoch

Kind of what I figured and even though I don't like the duplication, creating 2 enums is easy enough.  Thanks.

Information The latest build of this product (2018.1 build 0670) was released 7 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.