Friday, 19 September 2014

Creation of a Form using X++ code

                                 Creation of a Form using X++ code

To write an X++ job to create a basic form with a Tab page and inside a grid having two contols and we are taking PurchTable as Datasourse.

Job:

static void FormCreation(Args _args)
{
Form form;
FormRun formRun;
Args args;
FormBuildDesign formBuildDesign;
FormBuildControl formBuildControl;
FormBuildTabControl formBuildTabControl;
FormBuildTabPageControl formBuildTabPageControl;
FormBuildGridControl formBuildGridControl;
FormBuildDatasource formBuildDatasource;
FormBuildStringControl formString1;
;

form = new Form();

formBuildDatasource = form.addDataSource(tableStr(PurchTable));
formBuildDesign = form.addDesign("design");

formBuildTabControl = formBuildDesign.addControl(FormControlType::Tab, "Tab");
formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, "TabPage1");

formBuildGridControl = formBuildTabPageControl.addControl(FormControlType::Grid, "Grid");
formString1 = formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(PurchTable, PurchId));

formString1.label("PurchIds");
formString1 = formBuildGridControl.addControl(FormControlType::Real,"albion");

formString1.label("RaelValue");

args = new Args();
args.object(form);
formRun = classFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}



Run the job and see................... the following form





No comments:

Post a Comment