Add Objects to the Table

The ITabObjects interface is used to work with table objects.

The example of two shapes adding and grouping in regular report with the REPORT_TAB identifier is given.

Ellipse and triangle will be added and then they will be grouped. As a result the table looks as follows:

Example

Executing the example requires to add links to the Drawing, Metabase, Report, Tab system assemblies.

Sub Objects;
Var
    mb: IMetabase;
    Report: IPrxReport;
    Table: ITabSheet;
    Objs: ITabObjects;
    Obj, Obj1: ITabObject;
    Placement: IGxRectF;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get regular report
    Report := mb.ItemById("REPORT_TAB").Edit As IPrxReport;
    // Get table
    Table := (Report.ActiveSheet As IPrxTable).TabSheet;
    // Get report objects collection
    Objs := Table.Objects;
    // Clear collection
    Objs.Clear;
    // Set first object layout
    Placement := New GxRectF.Create(10105035);
    // Add first object in collection
    Obj := Objs.Add("PrxShape", Placement);
    // Set text of the tooltip for the first object
    Obj.Tooltip := "Ellipse";
    // Set type of the first object - ellipse
    (Obj As iprxShape).Type := PrxShapeType.Ellipse;
    // Set layout of the second object
    Placement := New GxRectF.Create(50357550);
    // Add the second object in collection
    Obj1 := Objs.Add("PrxShape", Placement);
    // Set text of the tooltip for the second object
    Obj1.Tooltip := "Triangle";
    // Set type of the second object - triangle
    (Obj1 As iprxShape).Type := PrxShapeType.Triangle;
    // Select both objects
    Obj.Select_;
    Obj1.Select_;
    // Merge selected objects in group
    Objs.GroupSelected;
    // Save changes
    (Report As IMetabaseObject).Save;
End Sub Objects;

See also:

General Programming Principles Using the Tab Assembly