Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide enum values on a combo box at runtime?

Suppose the combobox is linked to enum "ABC". The elements in it are A, B C and D.

Now I need to get only A and C in the combobox and not B and D?

Is this possible?

like image 930
Tejashree S Avatar asked Sep 16 '11 07:09

Tejashree S


People also ask

Is it possible to display enum values in a combobox?

However, while binding a combobox with enum, one can face a common problem that enum values are not user-friendly for display. So here, we will learn a way to show user-friendly enum names to end users. Please note that here, I have considered the implementation mentioned in the previous article, so please check that first before going further.

How do I assign an enum to an incompatible enum?

To assign an enum to another incompatible enum, just add zero to it! Or you can update your combobox using programming (using a combobox without specifying an enum type): See also Enum as a Parameter in Dynamics AX about adding new values to a combobox.

Are enum values not user-friendly for display?

In my previous article, we learned how to bind a combobox directly with the enum. However, while binding a combobox with enum, one can face a common problem that enum values are not user-friendly for display. So here, we will learn a way to show user-friendly enum names to end users.

How to delete enum values at runtime in Dynamics AX?

See also Enum as a Parameter in Dynamics AX about adding new values to a combobox. While it is not possible do delete enum values at runtime, it is possible to hide enum values for the entire application. Just change the enum value's ConfiguratioKey to "SysDeletedObjects40", and it disappears as a legal value.


2 Answers

Easy, create a run method in your form and put this:

public void run()
{
    super();

    YourCombo.delete(enum2str(YourEnum::B));
    YourCombo.delete(enum2str(YourEnum::D));
}

Regards

like image 160
Israel González Avatar answered Sep 21 '22 16:09

Israel González


It is not possible to delete enum values or combobox values.

You can duplicate the enum, then delete elements or change the order (but not the enum value). It will be your responsability to maintain both enum types synchronized with future changes.

To assign an enum to another incompatible enum, just add zero to it!

abc = myAbc + 0;

Or you can update your combobox using programming (using a combobox without specifying an enum type):

YourComboBox.add("A");
YourComboBox.add("C");

See also Enum as a Parameter in Dynamics AX about adding new values to a combobox.

While it is not possible do delete enum values at runtime, it is possible to hide enum values for the entire application. Just change the enum value's ConfiguratioKey to "SysDeletedObjects40", and it disappears as a legal value. I will assume that this configuration key is not enabled!

like image 35
Jan B. Kjeldsen Avatar answered Sep 22 '22 16:09

Jan B. Kjeldsen