Form Class

Today I will demonstrate you that how to use Form classes in AX 2012.

static void createForm(Args _args)
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign fbDesign;
FormBuildDataSource fbDS;
FormBuildGridControl fbGrid;
FormBuildTabControl fbTab;
FormBuildTabPageControl fbTabPage1;
DictTable dictTable;
FormControlType fctTabPage = FormControlType::TabPage;
FormControlType fctTab = FormControlType::Tab;
FormControlType fctGrid = FormControlType::Grid;
form = new Form();
dictTable = new DictTable(tablenum(CustTable));
fbDS = form.addDataSource(dictTable.name());
fbDS.table(dictTable.id());
fbDesign = form.addDesign("Design");
fbDesign.caption("Customer information");
fbTab = fbDesign.addControl(fctTab, "Overview");
fbTabPage1 = fbTab.addControl(fctTabPage, "Overview");
fbTabPage1.caption("Overview");
fbGrid = fbTabPage1.addControl(fctGrid,"Table Grid");
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("AccountNum"));
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("CustGroup"));
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("Currency"));
args = new Args();
args.object(form);
formRun = classfactory.formRunClass(args);
formRun.run();
formRun.detach();
}

Comments