Setting propperties on a FormControl without AutoDeclaration

  • March 19, 2010
  • 2 Comments

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);
  1. Björn left a comment on March 19, 2010 at 10:04 am

    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.

  2. Klaas Deforche left a comment on March 19, 2010 at 10:45 am

    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.

Comments are closed.