Selected Elements in a Combo Box

I guess this was one feature that was need of the hour for previous versions. Keeping only a subset of elements from elements in an enum.
Many a times we have seen that there is a requirement to remove some of the elements when they are shown in a combo-box on a form. Microsoft has come up with a class just for that purpose. The class is SysFormEnumComboBox.
Below is a sample code that depicts how to use this class on a form:
Code to write before the super() call in a form’s init method
//Declaration Section
SysFormEnumComboBox         sysFormEnumComboBox;
Set                                         enumSet = new Set(Types::Enum);
//Before super()
// Initialize the comboBox and fill it with values should be done before super() only
sysFormEnumComboBox = SysFormEnumComboBox::newParameters(element, Control::SamAddressType /*Id of the control*/, enumnum(AddressType), enumSet);
Code to be written after super() (Optional);
Now this class is available only in AX 2009. So how do we get this done in AX 4.0?
This is also pretty simple after the development of the class in AX 2009. Import the class SysFormEnumComboBox from AX 2009 into AX 4.0 and use it.
Other methods have been to use the delete method of Combo Box. Note that this changes the enum value of the elements.
Note: I just found out that this class works fine with unbounded controls and doesnt have any effect on Bounded controls. Will investigate more on this.

4 thoughts on “Selected Elements in a Combo Box

    1. A bound control means, a control attached to a datasource field (table field) and its data and behaviour is with respect to that field. An unbounded control is one which doesnt have any specific data field attached. Hope this clarifies your doubts.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s