Firing events on SubForm components

SubForm components are container components used to display other forms within a "parent" form.

The system treats SubForm components like Linked Child forms where form event handlers are concerned. That is, you can fire events from the parent form and make them effective with respect to the form in a SubForm component.

This example is a Visual Basic script that can be called from a form script method on a button in a parent form. When clicked, the script forces a save of any data in the child subform.

Option Explicit On
Option Strict On

Imports System
Imports Microsoft.VisualBasic
Imports Mongoose.IDO.Protocol
Imports Mongoose.Scripting

Namespace Mongoose.FormScripts
Public Class MPSaveOnSubform
Inherits FormScri

Sub SaveOnSubform()
  ThisForm.LinkedChildForms("YourSubForm").GenerateEvent("StdFormSave") 
End Sub

End Class 
End Namespace 

where:

  • YourSubForm is the name (not the caption) of the subform; for example, UsersMaint, not Users.
  • StdFormSave is the framework event that is being called to affect the subform.

Here is the same basic example in C#:

using System;
using Mongoose.IDO.Protocol;
using Mongoose.Scripting;

namespace Mongoose.FormScripts
{
public class MPSaveOnSubformCSharp : FormScript
{

public void SaveOnSubform()

{ ThisForm.LinkedChildForms["UserDefinedTypeValues"].GenerateEvent("StdFormSave"); }
}
}