Setting propperties on a FormControl without AutoDeclaration
When you want to set a property of a control on a form without setting the property AutoDeclaration = yes. You can address the control trough the following code, knowing that element is a FormRun-object:
element.design().controlName("btnOk").visible(false);
Tags: Dynamics AX, Forms, Programming, Tips & Tricks, X++
This entry was posted on Friday, March 19th, 2010 at 08:00 and is filed under Dynamics AX. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


March 19th, 2010 at 10:04
Handy trick indeed.
If you want a compile time check on the control name you can write it like this:
element.design().control(control::btnOk).visible(false);
Control is a special enum that maps a name to a control ID. It great for catching typos.
March 19th, 2010 at 10:45
Hi,
An other way is:
element.control(Control::btnOk).visible(false);
It is better (imo) because you will get a compilation error if the control does not exist. In your example, the compiler will not warn you if btnOk does not exist as a control.
Regards,
Klaas.