Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Retrieves a control on a form.
Syntax
public FormControl control(int controlId)
Run On
Client
Parameters
- controlId
Type: int
An Integer data type that specifies a control in a form.
Return Value
Type: FormControl Class
A FormControl object for a specified form control.
Remarks
Use the return value to instantiate various form control classes.
Examples
The following example shows a call to the control method that returns a grid control. The return value is used to instantiate the FormGridControl class. The FormGridControl.heightValue method specifies the height of the control.
static void createForm(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);
}