suite4.net.FormDatabase Documentation

IProject.GetForm Method 

Returns a reference to an IForm object with a specified name.

[Visual Basic]
Function GetForm( _
   ByVal formName As String _
) As IForm
[C#]
IForm GetForm(
   string formName
);

Parameters

formName
The name of the IForm. The formName value can be both the FullName or the Name of an IForm.

Return Value

A reference to an IForm object.

Example

The following example demonstrates how to load an IProject and get a reference to an IForm.

C# sample

using System;
using System.IO;
using suite4.net.FormDatabase;
namespace suite4.net.Sample
{
    public class Project
    {
        private IProject _project;
        public Project()
        {
        }
        public suite4.net.FormDatabase.IForm GetIForm(string formName)
        {
            FileInfo    fileInfo;
            if(this._project == null)
            {
                this._project = suite4.net.FormDatabase.Project.LoadFromFile("sample.fspj");
            }
            else
            {
                fileInfo = new FileInfo("sample.fspj");
                if(fileInfo.LastWriteTime > this._project.LastModification)
                {
                    // Reload the project if the project has been changed.
                    // This can be done during runtime.
                    this._project = suite4.net.FormDatabase.Project.LoadFromFile("sample.fspj");
                }
            }
            if(this._project != null)
            {
                return this._project.GetForm(formName);
            }
            return null;
        }
    }
}
            

VB.Net sample
Imports System
Imports System.IO
Imports suite4.net.FormDatabase
Namespace suite4.net.Sample
    Public Class Project
        Private _project As IProject
        Public  Sub New()
        End Sub
        Public Function GetIForm(ByVal formName As String) As suite4.net.FormDataMyBase.IForm
            Dim fileInfo As FileInfo
            If Me._project Is Nothing Then
                Me._project = suite4.net.FormDataMyBase.Project.LoadFromFile("sample.fspj")
            Else
                fileInfo = New FileInfo("sample.fspj")
                If fileInfo.LastWriteTime > Me._project.LastModification Then
                    ' Reload the project if the project has been changed.
                    ' This can be done during runtime.
                    Me._project = suite4.net.FormDataMyBase.Project.LoadFromFile("sample.fspj")
                End If
            End If
            If Not Me._project Is Nothing Then
                Return Me._project.GetForm(formName)
            End If
            Return Nothing
        End Function
    End Class
End Namespace
            

See Also

IProject Interface | suite4.net.FormDatabase Namespace