LoaderForm and LoaderControl Components

Using the form.suite4.net FormDatabase component, existing forms can be dynamically loaded and used in both Web and Windows environments. For .NET Windows Forms, this functionality is the responsibility of the LoaderForm and LoaderControl components. Both can load a form or user control that has been defined in the form.suite4.net application and display it.

The LoaderControl and LoaderForm perform slightly different functions but their purpose is the same: to read a form or user control from a form.suite4.net project file and display it on a .NET Windows Form.

The LoaderControl can be used like a regular System.Windows.Forms.UserControl at design time; it can be placed on a System.Windows.Forms.Form or into container controls such as the TabPage. The LoaderForm, on the other hand, is better suited for use in an MDI-environment or as a dialog window.

Note that neither the LoaderControl nor the LoaderForm make a distinction in regards to the elements they load and display — form.suite4.net Forms and UserControls are treated alike (through the IForm interface).

Because form definitions are read dynamically from the form.suite4.net project file, all updates can be performed in a central location — the form.suite4.net designer — and changes will be visible immediately without the need to re-compile (and re-deploy) the application.

The RootControl property

In addition to simply loading and displaying form.suite4.net forms and user controls, the LoaderControl and LoaderForm components provide the means to modify the properties of existing System.Windows.Forms.Form or System.Windows.Forms.UserControl instances. This is achieved through the use of the RootControl property.

Essentially, you can mask an existing Form/Control with a form.suite4.net IForm. During the loading process the IForm overrides each property of the Form/Control with the same name and type as one of its own, effectively resulting in a merge between the Form/Control and the IForm.

Possible uses of this technique include showing/hiding of controls based on user roles, or localization of form labels for different user languages.

Note: another approach to localization encompasses the use of form.suite4.net visual form inheritance.