CreateTableShape: IWxTableShape;
The CreateTableShape method creates a table shape.
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.
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(50, 40);
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(0, 3).Value := "Error";
TSheet.Cell(3, 0).Value := "Total";
TShape.AdjustSize;
TShape.EndUpdate;
End Sub Button1OnClick;
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: