Wednesday, June 3, 2015

Dynamic dialog controls at runtime

This is a job that demonstrates how to dynamically add controls (specifically radio button) to a dialog at runtime and also change their position and access their values.

You can use this style in custom advanced UI builders.

static void AKDynamicDialogExample(Args _args)
    Dialog                  dialog = new Dialog();
    FormBuildRadioControl   fbRadioControl;
    FormRadioControl        radioControl;
    // Add the radio button, name it anything
    fbRadioControl = dialog.formBuildDesign().addControl(FormControlType::RadioButton, 'RadioButton1');

    // Set radio basic properties
    fbRadioControl.caption("Test Radio Buttons");
    fbRadioControl.items(2); // This is needed

    fbRadioControl.item(1); // Switch to first item
    fbRadioControl.text("Item 1"); // Set first item's text
    fbRadioControl.item(2); // Switch to second item
    fbRadioControl.text("Item 2"); // Set second item's text

    // This is needed to instantiate the FormRun

    // Just passing one argument moves it UP.
    // So this moves it UP above the "OK/Cancel" buttons created

    if (dialog.closedOk())
        // You need to access it from the formRun() with the correct
        // form control
        radioControl = dialog.formRun().control(;
        info(strFmt("%1", radioControl.selection()));

1 comment:

  1. Dynamic dialogue is conducted and arranged between the two men of the quality. It is tristful and ability oriented. It is ascertained with the future endeavors and all prospective goals. It is mentioned and admired bestessay the new and all such terms it is circumstantial and progressive in all terms and conditions.