sm k
2011-04-21 09:51:22 UTC
There is a form with mix of controls including a grid control. On the click of the button, i need to delete the existing grid and build a new grid with new columns without closing the form.
I am able to add a grid control and run as new instance of the existing form.
Could anyone suggest to refresh/ rebuild the grid in the same instance of the form and not as a new instance.
Sample Code:
void CreateGrid(Args _args, str _formname)
{
Form form;
FormBuildDesign design;
FormBuildDataSource ds;
FormBuildGridControl grid;
Args args;
FormRun formRun;
;
form = new Form(_formname,false);//formstr("AddGridForm"));
ds = form.dataSource(1);
form.dataSource(1).table();
ds.table(form.dataSource(1).table());
design = form.design();
grid = design.addControl(FormControlType::Grid, "Grid1");
grid.dataSource(ds.id());
grid.widthMode(FormWidth::ColumnWidth);
grid.heightMode(FormHeight::ColumnHeight);
grid.addDataField(ds.id(),fieldnum(InventTable,ItemId));
grid.addDataField(ds.id(),fieldnum(InventTable, ItemGroupId));
args = new Args();
args.object(form);
formRun = new formrun(args);
formrun.init();
formrun.run();
formrun.detach();
}
I am able to add a grid control and run as new instance of the existing form.
Could anyone suggest to refresh/ rebuild the grid in the same instance of the form and not as a new instance.
Sample Code:
void CreateGrid(Args _args, str _formname)
{
Form form;
FormBuildDesign design;
FormBuildDataSource ds;
FormBuildGridControl grid;
Args args;
FormRun formRun;
;
form = new Form(_formname,false);//formstr("AddGridForm"));
ds = form.dataSource(1);
form.dataSource(1).table();
ds.table(form.dataSource(1).table());
design = form.design();
grid = design.addControl(FormControlType::Grid, "Grid1");
grid.dataSource(ds.id());
grid.widthMode(FormWidth::ColumnWidth);
grid.heightMode(FormHeight::ColumnHeight);
grid.addDataField(ds.id(),fieldnum(InventTable,ItemId));
grid.addDataField(ds.id(),fieldnum(InventTable, ItemGroupId));
args = new Args();
args.object(form);
formRun = new formrun(args);
formrun.init();
formrun.run();
formrun.detach();
}