动态创建并运行一个Form

static void CretateForm(Args _args)

{

    Args args;

    Form form;

    FormRun formRun;

    FormBuildDesign formBuildDesign;

    FormBuildDataSource formBuildDataSource;

    FormBuildGridControl formBuildGridControl;

    FormGridControl formGridControl;

    DictTable dictTable;

    int idx;

    int height;

 

    ;

 

    // Create the form header.

    form = new Form();

 

    form.name("myForm");

    // 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');

 

    // Add a grid control.

    formBuildGridControl =

    formBuildDesign.addControl(FormControlType::Grid,'Grid');

    idx = formBuildGridControl.id();

 

    formBuildGridControl.addDataField(formBuildDataSource.id(),

    dictTable.fieldName2Id("AccountNum"));

    formBuildGridControl.addDataField(formBuildDataSource.id(),

    dictTable.fieldName2Id("Phone"));

 

    args = new Args();

    args.object(form);

 

    // Create the run-time form.

    formRun = classfactory.formRunClass(args);

 

    formRun.run();

    formRun.detach();

 

    formGridControl = formRun.control(idx);

    formGridControl.heightMode(-1); // Fixed.

    height = formGridControl.heightValue(120);

}

    posted @ 2011-07-27 12:07  perock  阅读(294)  评论(0编辑  收藏  举报