Share via


FormRun.defaultDataSource Method

Sets or returns a FormObjectSet object for a specified default form data source.

Syntax

public FormObjectSet defaultDataSource([FormObjectSet value])

Run On

Client

Parameters

  • value
    Type: FormObjectSet Class
    A FormObjectSet object that specifies the default form data source; optional.

Return Value

Type: FormObjectSet Class
A FormOjectSet object for a specified default form data source.

Remarks

You can use a FormDataSource class object for the value parameter.

You must specify the default form data source by using a valid value parameter; otherwise, the return value is null Nothing nullptr unit a null reference (Nothing in Visual Basic) .

You can use the return value from the defaultDataSource method to instantiate the FormDataSource class.

Examples

The following example shows a call to the defaultDataSource method to specify the first data source that is added to the form as the default data source. The Form.addDataSource method adds two data sources to the form.

static void createForm2(Args _args) 
{ 
    Args args; 
    Form form; 
    FormRun formRun; 
    FormBuildDesign formBuildDesign; 
    FormBuildDataSource formBuildDataSource; 
    FormBuildDataSource formBuildDataSource2; 
    FormBuildGridControl formBuildGridControl; 
    FormDataSource formDataSource; 
    DictTable dictTable; 
    DictTable dictTable2; 
    int idx;  
    // 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()); 
    dictTable2 = new DictTable(78); 
    formBuildDataSource2 = form.addDataSource(dictTable2.name()); 
    formBuildDataSource2.table(dictTable2.id()); 
 
    // Create the form design. 
    formBuildDesign = form.addDesign("Design"); 
 
    // Add a grid control. 
    formBuildGridControl = 
 formBuildDesign.addControl(FormControlType::Grid, "Table Grid"); 
    formBuildGridControl.dataSource(dictTable.name()); 
 
    // Add a data field to the grid control. 
    formBuildGridControl.addDataField(formBuildDataSource.id(), 
    dictTable.fieldName2Id("AccountNum")); 
 
    args = new Args(); 
    args.object(form); 
 
    // Create the run-time form. 
    formRun = new FormRun(Args); 
    formRun.run(); 
    formRun.detach(); 
 
    // Return an object for the first data source, 
    // and then specify the default data source. 
    formdatasource = formRun.dataSource(1); 
    formdatasource = formRun.defaultDataSource(formdatasource); 
}

See Also

Reference

FormRun Class