EnumEditBox - Omit Values

Editors for WPF Forum

Posted 3 years ago by Justin Klein
Version: 16.1.0635
Avatar

Is it possible to have an EnumEditBox only present a subset of the available values?

 

I have an enum with values like value1, value2, value3, uninitialized - I'd like to omit "uninitialized" from being selected by the user.  The 'uninitialized' value will never be set to the bound property once the editbox is shown.

Comments (10)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Justin,

No, it will currently show all possible options.  Perhaps if we added logic that would not show an enum value if you set Browsable(false) on it, that would help?  We can write that down as a feature request.


Actipro Software Support

Posted 3 years ago by Justin Klein
Avatar

Sure, that would work :)

Posted 3 years ago by Justin Klein
Avatar

Just curious, is this something that might end up in the nearish future?  No pressure, I realize things take time, I'm just asking because there's a product to ship, so if it's a long wait I'll probably just go ahead & write my own control - but if it's soonish, I'll hang tight :)

Answer - Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Justin,

We've got this working for 2017.1.  Basically if you put [EditorBrowsable(EditorBrowsableState.Never)] on the enum value, it won't show in the EnumEditBox drop-down and pressing up/down won't cycle to it either (skips over it).


Actipro Software Support

Posted 3 years ago by Justin Klein
Avatar

Nice!! What a quick turnaround :)  Is 2017.1 available for download somewhere? I see the latest release as 2016.1 build 0635.

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

We just started a private beta to some customers before we open it up to others.  The EnumEditBox update isn't in the beta just yet but will roll into the next build.  Do you have Slack?  If you want to help beta test, that would be easiest since then you can keep up to date with beta news.  Or if you don't want to use Slack, you could email our support address.


Actipro Software Support

Posted 3 years ago by Justin Klein
Avatar

Great, sent!

Posted 2 years ago by Imre Lengyel
Avatar

Hello, One thing that I did not expect was that the ommitted value type is still shown when the combination of flags that represent it is selected as the value:

    [Flags]
    public enum EnumDst2
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        None = 0,
        One = 1,
        Two = 2,

        [EditorBrowsable(EditorBrowsableState.Never)]
        All = 3
    }

 Gives (ascii diagram because i cant find add picture button):

+-----------------+
| All         | v | 
+-----------------+
| [/] One         |
| [/] Two         |
+-----------------+

I would have expected it as if it was not defined, i.e.

+-----------------+
| One, Two    | v |
+-----------------+
| [/] One         |
| [/] Two         |
+-----------------+
Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I'm not sure we can really do anything about that since it's the string value that comes from Enum method calls.

You could probably work around it by adding a DescriptionAttribute to All that is "One, Two" and enable the EnumEditBox.UseDisplayAttributes property.


Actipro Software Support

Posted 2 years ago by Imre Lengyel
Avatar

Ok, that works. Another option I found to work, would be to create a 'proxy enum' leaving out the combined flags and cast in the getters/setters, this way would avoid the need to modify enums that are defined outside our control. 

Another peculiar thing I found specifying an empty string or null for DescriptionAttribute falls back to the enum field name. Which is a bit anoying in the case of None = 0 I want to show nothing. Leaving it out shows the number '0'. I worked around this by specifying an invisible character, eg space.

The latest build of this product (v2019.1 build 0683) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.