How to add a button to a dialog and create a method for the click event

stighy picture stighy · Jun 26, 2012 · Viewed 11.4k times · Source

In Axapta, How to add a button to a dialog and intercept the click event? Thanks

Answer

AnthonyBlake picture AnthonyBlake · Jun 26, 2012

Option 1;

This line is needed in dialog run()

element.controlMethodOverload(true);

The you can overload the click event;

public void MyButton_clicked()
{
//bla
}

Option 2;

Put your button action code in a separate class, and create a menu option, the add a menu item button to execute your code;

dialog.addMenuItemButton(MenuItemType::Action,"YourNewMenuItem");

Which you use depends upon what you are trying to achieve really.