IFormControl.PostCommand

Syntax

PostCommand(Command: String; [Argument: Variant = Null]);

Parameters

Command. Name of the command that will be sent to the form.

Argument. Command argument.

Description

The PostCommand method enables sending a command to a form.

Comments

Commands are processed in the Form.OnCommand event.

NOTE. This method is executed after all commands in the individual procedure.

Example

Executing the example requires two forms:

Add a link to the DESTINATIONFORM form in the assembly inspector in the SOURCEFORM form. Add the Public access modifier for the DESTINATIONFORM form class and to the descriptions of the Label1 component.

Add the OnClick event handler for the Button1 button with the following code:

Class SOURCEFORMForm: Form
    Button1: Button;
    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        DestForm: DESTINATIONFORMForm;
    Begin
        DestForm := New DESTINATIONFORMForm.CreateForm;
        DestForm.PostCommand("ChangeLabel""LastName");
        DestForm.Label1.Text := "NewName";
        DestForm.Visible := True;
    End Sub Button1OnClick;
End Class SOURCEFORMForm;

Add the OnCommand event handler for the DESTINATIONFORM form with the following code:

Public Class DESTINATIONFORMForm: Form
    Public Label1: Label;
    Sub DESTINATIONFORMFormOnCommand(Sender: Object; Args: ICommandEventArgs);
    Begin
        If Args.Command = "ChangeLabel" Then
            Label1.Text := Args.Argument As String;
        End If;
    End Sub DESTINATIONFORMFormOnCommand;
End Class DESTINATIONFORMForm;

Clicking the Button1 button creates an instance of the DESTINATIONFORM form and the ChangeLabel command with the LastName argumnet is sent to it. This command should rename the text of the Label1 component into LastName. The next line changes the Label1 text for NewName, but because of the PostCommand method execution after all the rest commands, the Label1 component text will be equal to LastName.

See also:

IFormControl