Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFPlugIn.CreateFormInstance Method

  • Last UpdatedNov 18, 2025
  • 4 minute read
AFPlugIn.CreateFormInstance Method
Create an instance of a plugin editor form.

Namespace:  OSIsoft.AF
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public Form CreateFormInstance(
	Type type,
	Object plugIn,
	bool readOnly
)
Public Function CreateFormInstance ( 
	type As Type,
	plugIn As Object,
	readOnly As Boolean
) As Form

Dim instance As AFPlugIn
Dim type As Type
Dim plugIn As Object
Dim readOnly As Boolean
Dim returnValue As Form

returnValue = instance.CreateFormInstance(type, 
	plugIn, readOnly)
public:
Form^ CreateFormInstance(
	Type^ type, 
	Object^ plugIn, 
	bool readOnly
)
member CreateFormInstance : 
        type : Type * 
        plugIn : Object * 
        readOnly : bool -> Form 

Parameters

type
Type: SystemType
The Type of the editor form to create.
plugIn
Type: SystemObject
The plugin instance being configured by the editor form.
readOnly
Type: SystemBoolean
If , then the editor form will be read-only. If , then the values can be modified.

Return Value

Type: Form
Returns the newly created plugin editor form instance.

Remarks

Typically, it is not necessary to invoke this method. This method is used internally by the AFPlugInEditor.

Examples

// This example demonstrates how to create a model analysis and display the
// configuration dialog for the Analysis Rule and Time Rule plugins.
// Note: This example assumes that there is a database called "Chocolate Milk Tutorial"
// containing a Model named "ChocolateMilkModel", and the default ConfigString
// for an "Imbalance" analysis rule is set

// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
AFDatabase myDB = myPISystem.Databases["Chocolate Milk Tutorial"];

// Set the Model
AFModel myModel = myDB.Elements["ChocolateMilkModel"] as AFModel;

// Add an Analysis to the model
AFModelAnalysis myAnalysis = new AFModelAnalysis(myDB, "MyModelAnalysis");
myAnalysis.Description = "This is a model analysis example";
myAnalysis.Target = myModel;

// Set the Analysis Rule and Time Rule
myAnalysis.AnalysisRulePlugIn = myPISystem.AnalysisRulePlugIns["Imbalance"];
myAnalysis.TimeRulePlugIn = myPISystem.TimeRulePlugIns["Periodic"];

// Display the Time Rule Configuration Dialog
AFPlugIn plugin = myAnalysis.TimeRulePlugIn;
AFTimeRule timeRule = myAnalysis.TimeRule;
if (plugin != null)
{
    using (Form configDlg = plugin.CreateFormInstance(timeRule.EditorType, timeRule, false))
    {
        if (configDlg != null)
            configDlg.ShowDialog();
    }
}

// Display the Analysis Rule Configuration Dialog
plugin = myAnalysis.AnalysisRulePlugIn;
AFAnalysisRule analysisRule = myAnalysis.AnalysisRule;
if (plugin != null)
{
    using (Form configDlg = plugin.CreateFormInstance(analysisRule.EditorType, analysisRule, false))
    {
        if (configDlg != null)
            configDlg.ShowDialog();
    }
}
' This example demonstrates how to create a model analysis and display the
' configuration dialog for the Analysis Rule And Time Rule plugins.
' Note: This example assumes that there is a database called "Chocolate Milk Tutorial"
' containing a Model named "ChocolateMilkModel", and the default ConfigString
' for an "Imbalance" analysis rule is set

' Get the Database
Dim myPISystems As New PISystems
Dim myPISystem As PISystem = myPISystems.DefaultPISystem
Dim myDB As AFDatabase = myPISystem.Databases("Chocolate Milk Tutorial")

' Set the Model
Dim myModel As AFModel = CType(myDB.Elements("ChocolateMilkModel"), AFModel)

' Add a ModelAnalysis to the model
Dim myAnalysis As New AFAnalysis(myDB, "MyModelAnalysis")
myAnalysis.Description = "This is a model analysis example"
myAnalysis.Target = myModel

' Set the Analysis Rule and Time Rule
myAnalysis.AnalysisRulePlugIn = myPISystem.AnalysisRulePlugIns("Imbalance")
myAnalysis.TimeRulePlugIn = myPISystem.TimeRulePlugIns("Periodic")

' Display the Time Rule Configuration Dialog
Dim plugin As AFPlugIn = myAnalysis.TimeRulePlugIn
Dim timeRule As AFTimeRule = myAnalysis.TimeRule
If Not plugin Is Nothing Then
    Using configDlg As Form = plugin.CreateFormInstance(timeRule.EditorType, timeRule, False)
        If Not configDlg Is Nothing Then
            configDlg.ShowDialog()
        End If
    End Using
End If

' Display the Analysis Rule Configuration Dialog
plugin = myAnalysis.TimeRulePlugIn
Dim analysisRule As AFAnalysisRule = myAnalysis.AnalysisRule
If Not plugin Is Nothing Then
    Using configDlg As Form = plugin.CreateFormInstance(analysisRule.EditorType, analysisRule, False)
        If Not configDlg Is Nothing Then
            configDlg.ShowDialog()
        End If
    End Using
End If

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK


See Also

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in