IPPButtonGroup.Add

Syntax

Add(pButton: IPPButton);

Parameters

pButton. The button to be included into the group.

Description

The Add method adds the specified button to the group.

Comments

The button implemented by the PPSwitchButton class must be specified as value of the pButton parameter. The button is added to the end of the group. When the button is added to the group as a parent component, the current PPButtonGroup component is automatically defined for this button.

Example

Executing the example requires a form that contains the PPButtonGroup component named PPButtonGroup1.

Class SampleForm: Form
    PPButtonGroup1: PPButtonGroup;

    Sub PPBUTTONGROUP_SAMPLEFormOnCreate(Sender: Object; Args: IEventArgs);
    Var
        b1, b2, b3: PPSwitchButton;
    Begin
        Self.BeginUpdate;
        b1 := New PPSwitchButton.Create;
        b2 := New PPSwitchButton.Create;
        b3 := New PPSwitchButton.Create;
        b1.Name := "b1";
        b2.Name := "b2";
        b3.Name := "b3";
        b1.Text := "Normal";
        b2.Text := "Bold";
        b3.Text := "Italic";
        b1.OnClick := BtnOnClick;
        b2.OnClick := BtnOnClick;
        b3.OnClick := BtnOnClick;
        b1.Down := True;
        PPButtonGroup1.Add(b1);
        PPButtonGroup1.Add(b2);
        PPButtonGroup1.Add(b3);
        Self.EndUpdate;
    End Sub PPBUTTONGROUP_SAMPLEFormOnCreate;
    
    Sub BtnOnClick(Sender: Object; Args: IMouseEventArgs);
    Begin
        Select Case (Sender As IControl).Name
            Case "b1"//Process an action for the button b1
            Case "b2"//Process an action for the button b2"
            Case "b3"//Process an action for the button b3
        End Select;
    End Sub BtnOnClick;
    
End Class SampleForm;

On starting the form three PPButton buttons are dynamically created and added to the group of the PPButtonGroup1 component. A handler of the OnClick event will be set for all the buttons. This handler will determine which of the buttons was pressed by button name.

See also:

IPPButtonGroup