Add a form list control. in form at runtime using axapta
static void createForm2(Args _args)
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign formBuildDesign;
FormBuildDataSource formBuildDataSource;
FormBuildListControl formBuildListControl;
FormListControl formListControl;
FormListItem formListItem;
FormListColumn formListColumn1;
FormListColumn formListColumn2;
FormListColumn formListColumn;
DictTable dictTable;
int idx4;
str string;
container conAccountNum;
CustTable custTable;
int numAccounts;
int i;
int item;
int numItems;
;
// Create the form header.
form = new Form();
// Add data sources to the form.
dictTable = new DictTable(tableNum(custTable));
formBuildDataSource = form.addDataSource(dictTable.name());
formBuildDataSource.table(dictTable.id());
// Create the form design.
formBuildDesign = form.addDesign("Design");
formBuildDesign.caption("myForm");
// Add a form list control.
formBuildListControl =
formBuildDesign.addControl(FormControlType::ListView,"List");
idx4 = formBuildListControl.id();
args = new Args();
args.object(form);
// Create the run-time form.
formRun = classfactory.formRunClass(args);
formRun.run();
formRun.detach();
formListControl = formRun.control(idx4);
formListControl.viewType(FormListViewType::Report);
formListControl.height(120);
formListControl.widthMode(FormWidth::ColumnWidth);
formListControl.rowSelect(true);
// Add columns to the form list control.
formListControl.addColumn(1, new FormListColumn("Column1",1,120));
formListControl.addColumn(2, new FormListColumn("Column2",2,120));
// Add items to the form list control.
while select custTable
where custTable.AccountNum >=
"4000" && custTable.AccountNum <= "4040"
{
conAccountNum += [[custTable.AccountNum]];
}
numAccounts = conlen(conAccountNum);
for(i = 1; i <= numAccounts; i++)
{
string = conPeek(conAccountNum,i);
formListItem = new FormListItem(string);
item = formListControl.addItem(formListItem);
}}
l
static void createForm2(Args _args)
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign formBuildDesign;
FormBuildDataSource formBuildDataSource;
FormBuildListControl formBuildListControl;
FormListControl formListControl;
FormListItem formListItem;
FormListColumn formListColumn1;
FormListColumn formListColumn2;
FormListColumn formListColumn;
DictTable dictTable;
int idx4;
str string;
container conAccountNum;
CustTable custTable;
int numAccounts;
int i;
int item;
int numItems;
;
// Create the form header.
form = new Form();
// Add data sources to the form.
dictTable = new DictTable(tableNum(custTable));
formBuildDataSource = form.addDataSource(dictTable.name());
formBuildDataSource.table(dictTable.id());
// Create the form design.
formBuildDesign = form.addDesign("Design");
formBuildDesign.caption("myForm");
// Add a form list control.
formBuildListControl =
formBuildDesign.addControl(FormControlType::ListView,"List");
idx4 = formBuildListControl.id();
args = new Args();
args.object(form);
// Create the run-time form.
formRun = classfactory.formRunClass(args);
formRun.run();
formRun.detach();
formListControl = formRun.control(idx4);
formListControl.viewType(FormListViewType::Report);
formListControl.height(120);
formListControl.widthMode(FormWidth::ColumnWidth);
formListControl.rowSelect(true);
// Add columns to the form list control.
formListControl.addColumn(1, new FormListColumn("Column1",1,120));
formListControl.addColumn(2, new FormListColumn("Column2",2,120));
// Add items to the form list control.
while select custTable
where custTable.AccountNum >=
"4000" && custTable.AccountNum <= "4040"
{
conAccountNum += [[custTable.AccountNum]];
}
numAccounts = conlen(conAccountNum);
for(i = 1; i <= numAccounts; i++)
{
string = conPeek(conAccountNum,i);
formListItem = new FormListItem(string);
item = formListControl.addItem(formListItem);
}}
l