dotConnect for MongoDB Documentation
On this page
    InterForm Technology
    On this page
    Note InterForm technology is available only for the full .NET Framework.

    Applications with multiple forms often use a centralized data access architecture in which database connections and data components are shared across forms. However, configuring these shared components at design time can be challenging. For example, accessing live data through a shared database connection or using a centralized data module may require additional code to manage references between forms.

    InterForm technology in dotConnect for MongoDB addresses these challenges by letting components on different forms within a Windows Forms (WinForms) application reference one another at design time. It enables shared database connections, centralized data access, and cross-form component references without additional code, while maintaining a centralized application architecture.

    This article explains how InterForm works, its requirements and limitations, and how to use it in WinForms applications.

    InterForm Fundamentals

    InterForm lets you create references to components located on other forms directly in the Visual Studio designer.

    To create a cross-form reference, select the component's reference property in the Properties window, click the dropdown button, and locate the required component in the tree.

    When you select a component, dotConnect for MongoDB performs two actions:

    1. Establishes a reference to the selected component so it can be used immediately.
    2. Creates a virtual link that identifies the referenced component by name.

    A virtual link consists of the form name, component name, and, optionally, the name of a nested component.

    For example, if a DataLink component references the table1 table in the dataSet1 MongoDBDataSet component located on the MyForm form, the virtual link has the following format:

    MyForm.dataSet1.table1

    When the referencing component is loaded at design time or run time, dotConnect for MongoDB attempts to resolve the virtual link to the actual component.

    InterForm supports properties that reference the following component types:

    When a component on a base form is referenced from another form, the reference points to the component on the base form. If you create a derived form, the reference continues to point to the original component on the base form rather than the corresponding component on the derived form.

    Requirements

    For InterForm references to work correctly, the following requirements must be met:

    Limitations

    InterForm technology has the following limitations:

    Use Cases and Recommendations

    For applications that use InterForm, we recommend placing shared data access components on a dedicated form. Create this form before other forms at run time and keep it open in the Visual Studio designer. This approach centralizes data access components, simplifies their configuration, and helps prevent reference resolution issues.

    The following examples demonstrate common scenarios where InterForm can be useful.

    Applications with multiple forms often need to share a single database connection. Without InterForm, you typically need to pass the connection between forms programmatically, which limits the ability to configure and use it at design time. InterForm lets you configure a shared MongoDBConnection component and reference it from other forms.

    To share a connection:

    1. Add and configure a MongoDBConnection component on a dedicated form.
    2. Ensure that this form is created before any forms that reference the connection at run time.
    3. In other forms, configure the data access components to reference the shared connection using InterForm.

    You can then manage the connection settings in one location while retaining design-time access to the shared connection.

    In applications with multiple forms, several controls may need to use the same data source. InterForm works with the DataLink component to provide shared data access across forms. For the configuration steps, see the Use Case section of DataLink Component Architecture.

    See Also

    DataLink Component Architecture  | MongoDBConnection Class  | MongoDBDataSet Class