FormRun.selectTarget Method
Selects a control in a form.
Syntax
public FormControl selectTarget([FormControl target])
Run On
Client
Parameters
- target
Type: FormControl Class
A FormControl object that specifies a control in a form; optional.
Return Value
Type: FormControl Class
A FormControl object that specifies a control in a form.
Examples
The following example shows a call to the selectTarget method to select the grid control. The FormGridControl.showColLabels method indicates whether column headings appear in the control.
static void createForm2(Args _args)
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign formBuildDesign;
FormBuildDataSource formBuildDataSource;
FormBuildGridControl formBuildGridControl;
FormBuildStringControl formBuildStringControl;
FormStringControl formStringControl;
FormGridControl formGridControl;
DictTable dictTable;
int idx;
int idx2;
// 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");
// Add controls.
formBuildGridControl =
formBuildDesign.addControl(FormControlType::Grid, "Table Grid");
formBuildGridControl.dataSource(dictTable.name());
idx = formBuildGridControl.id();
formBuildStringControl =
formBuildDesign.addControl(FormControlType::String, "Table String");
formBuildStringControl.dataSource(dictTable.name());
idx2 = formBuildStringControl.id();
// Add data fields to the controls.
formBuildGridControl.addDataField(formBuildDataSource.id(),
dictTable.fieldName2Id("AccountNum"));
formBuildGridControl.addDataField(formBuildDataSource.id(),
dictTable.fieldName2Id("Phone"));
formBuildStringControl.dataSource(formBuildDataSource.id());
formBuildStringControl.dataField(1);
args = new Args();
args.object(form);
// Create the run-time form.
formRun = new FormRun(args);
formRun.run();
formRun.detach();
// Select the grid control.
formGridControl = formRun.control(idx);
formGridControl = formRun.selectTarget(formGridControl);
formGridControl.showColLabels(false);
}