1

If you have an enum which is used in more than one place, and at one of the places you need to hide one of the elements?

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Raas
  • 261
  • 8
  • 25

2 Answers2

1

Hiding enum elements on runtime ax 2012

1.Override enter() on created ComboBox and write this code:

this.delete(enum2str(EnumType::Element1)); super();

Now run form and check. Element1 is the element which you need to hide.

This worked for me.

Community
  • 1
  • 1
Raas
  • 261
  • 8
  • 25
  • This only works when the enum values that you want to remove are the last values. Otherwise the value no longer matches the selection. Example enum [0=A, 1=B, 2=C]. Deleting the last value 'C' will leave [0=A, 1=B], which is correct. Deleting 'A' will result in [0=B, 1=C] ==> the integer values no longer match the original enum. – Sander Jul 19 '16 at 07:56
1

Also consider using SysFormEnumComboBox.

The SysFormEnumComboBox class facilitates work with a form combo box control, representing an enumeration when only some of the enumeration values are allowed.

See this blog post for an example.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50