-->

Adding a button to a dialog

2019-07-27 08:49发布

问题:

Are AX dialog buttons limited to OK and Cancel?
Is it possible to add a custom button to the dialog?

I have the following code for my dialog:

static void mitTabPage(Args _args)
{
    Dialog          dialog;
    DialogGroup     dialoggroup, dialoggroup2;
    DialogField     dialogfield, dialogfield2;
    ;
    dialog      = new Dialog ("A new Dialog");

    dialog.addTabPage("Brand Id's");
    dialoggroup = dialog.addGroup("Brand Id's");
    dialogfield = dialog.addField(extendedTypeStr(SYCCarBrandId));

    dialog.addTabPage("Owners");
    dialoggroup2    = dialog.addGroup("Owners");
    dialogfield2    = dialog.addField(extendedTypeStr(SYCOwner));

    dialog.run();
}

I'd like to add another button to the dialog. How can I do that?

回答1:

The Dialog framework is a simple framework for prompting users to obtain some data/settings then performing some action or canceling.

For what you're trying to do, it most likely doesn't make sense to use the dialog framework and instead you could/should create another form if you need additional functionality.

However, if you do insist on using the Dialog framework for this, you would add a runtime button and use registerOverrideMethod.

See following links:

https://msdn.microsoft.com/en-us/library/dialogfield.registeroverridemethod.aspx

https://blogs.msdn.microsoft.com/axsupport/2015/06/07/using-x-to-add-a-control-at-runtime/