Show contents 

Tab > About the Tab Assembly > General Programming Principles using Tab Assembly > Add Objects to the Table

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:

Fore Example

To execute the example, 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;

Fore.NET Example

Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    Report: IPrxReport;
    Table: ITabSheet;
    Objs: ITabObjects;
    Obj, Obj1: ITabObject;
    Placement: GxRectF;
Begin
    // Get current repository
    mb := Params.Metabase;
    // 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 GxRectFClass.Create();
    Placement.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.pstEllipse;
    // Set layout of the second object
    Placement.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.pstTriangle;
    // Select both objects
    Obj.@Select();
    Obj1.@Select();
    // Merge selected objects in group
    Objs.GroupSelected();
    // Save changes
    (Report As IMetabaseObject).Save();
End Sub;

See also:

General Programming Principles Using the Tab Assembly