IWxWorkspace.CreateTableShape

Syntax

CreateTableShape: IWxTableShape;

CreateTableShape(): Prognoz.Platform.Interop.Andy.IWxTableShape;

Description

The CreateTableShape method creates a table shape.

Comments

On executing the method a new shape containing a table is created. By default, the table consists of three columns and one row. If required, their number can be changed using the following methods: IWxTableShape.AddColumnWithFixedWidth/IWxTableShape.AddRowWithFixedHeight.

Example

Executing the example requires a form with the Button1 button, the WorkspaceBox component and the UiWorkspace component named UiWorkspace1, which is a data source for WorkspaceBox.

Add links to the Andy, Drawing, Metabase system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    w: IWxWorkspace;
    TShape: IWxTableShape;
    TSheet: ITabSheet;
    Cell: ITabRange;
    i, j: Integer;
Begin
    w := UiWorkspace1.WxWorkspace;
    //Create a new table shape
    TShape := w.CreateTableShape;
    TShape.Size := New GxSizeF.Create(5040);
    TShape.BeginUpdate;
    //Set up table
    TSheet := TShape.TabSheet;
    For i := 0 To 2 Do
        For j := 0 To 2 Do
            Cell := TSheet.Cell(i, j);
            Cell.Value := ...;//Values of cells
            Cell.Style.BorderStyle(TabBorder.Outline) := TabBorderStyle.Continuous;
        End For;
    End For;
    //Create another column
    TShape.AddColumnWithFixedWidth(20);
    TShape.AddRowWithFixedHeight(20);
    //Specify values for cells of the created column
    TSheet.Cell(03).Value := "Error";
    TSheet.Cell(30).Value := "Total";
    TShape.AdjustSize;
    TShape.EndUpdate;
End Sub Button1OnClick;

Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Drawing;

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    w: IWxWorkspace;
    TShape: IWxTableShape;
    GxSizeFCls: GxSizeFClass = New GxSizeFClass();
    TSheet: ITabSheet;
    Cell: ITabRange;
    i, j: Integer;
Begin
    w := UiWorkspaceNet1.WxWorkspace;
    //Create a new table shape
    TShape := w.CreateTableShape();
    GxSizeFCls.Create(5040);
    TShape.Size := GxSizeFCls;
    TShape.BeginUpdate();
    //Set up table
    TSheet := TShape.TabSheet;
    For i := 0 To 2 Do
        For j := 0 To 2 Do
            Cell := TSheet.Cell[i, j];
            Cell.Value := ...; //Values of cells
            Cell.Style.BorderStyle[TabBorder.tbOutline] := TabBorderStyle.tbsContinuous;
        End For;
    End For;
    //Create another column
    TShape.AddColumnWithFixedWidth(20);
    TShape.AddRowWithFixedHeight(20);
    //Specify values for cells of the created column
    TSheet.Cell[03].Value := "Error";
    TSheet.Cell[30].Value := "Total";
    TShape.AdjustSize();
    TShape.EndUpdate();
End Sub;

A new table shape is created on clicking the button. Values are specified for the cells of the table. Also, an additional column and one row are created in the table.

See also:

IWxWorkspace