McTable
class from the Multicad.Symbols.Tables
namespace. The following code fragment creates an empty table, and then adds 2 rows and 3 columns to it, starting from the zero position: McTable Table1 = new McTable(); int rowCount = 4; int colCount = 5; Table1.Rows.AddRange(0, rowCount + 1); Table1.Columns.AddRange(0, colCount);
// Sets color and text height that will be used for all table cells by default: Table1.DefaultCell.TextHeight = 2.5; Table1.DefaultCell.TextColor = System.Drawing.Color.Aqua; // The first row is the title, let's merge all its cells and set text alignment and height System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, colCount - 1, 0); Table1.Merge(rect); Table1[0, 0].HorizontalTextAlign = HorizTextAlign.Center; Table1[0, 0].VerticalTextAlign = VertTextAlign.Center; Table1[0, 0].TextHeight = 5; // Fill up the table foreach (var cell in Table1.Rows[2].Cells) { cell.VerticalTextAlign = VertTextAlign.Center; cell.HorizontalTextAlign = HorizTextAlign.Center; } Table1.Columns[0].Width = 10; Table1[0, 0].Value = " "; Table1[1, 0].Value = "."; Table1[1, 1].Value = ""; Table1[1, 2].Value = ", ."; Table1[1, 3].Value = ""; Table1[1, 4].Value = " "; Table1[2, 0].Value = "1."; Table1[2, 1].Value = ""; Table1[2, 2].Type = CellFormatEnum.Number; Table1[2, 2].Value = "1"; Table1[2, 3].Value = " "; Table1[2, 4].Value = "1938-1"; Table1[3, 0].Value = "2."; Table1[3, 1].Value = ""; Table1[3, 2].Type = CellFormatEnum.Number; Table1[3, 2].Value = "1"; Table1[3, 3].Value = " "; Table1[3, 4].Value = "0132-2"; Table1[4, 0].Value = "3."; Table1[4, 1].Value = ""; Table1[4, 2].Type = CellFormatEnum.Number; Table1[4, 2].Value = "1"; Table1[4, 3].Value = ""; Table1[4, 4].Value = "0715-7";
HorzFits
property HorzFits
you can set the following horizontal HorzFits
modes:HorizontalFitsEnum.None
- do not enter text, the text may overlap adjacent cells,HorizontalFitsEnum.Shrink
- compress text horizontally (the default mode),HorizontalFitsEnum.Wrap
- wrap by words.VertFits
property sets vertical text entry:VerticalFitsEnum.None
- do not enter text, the text may overlap adjacent cells,VerticalFitsEnum.Shrink
- reduce the font height (the default mode),VerticalFitsEnum.Expand
- increase line height,VerticalFitsEnum.AddRows
- add pseudo-lines for each line of text. Table1.Rows.CopyRange(4, 5, 1, true); Table1.Columns.Move(2,5); Table1.Columns.Delete(0);
Table1.Rows.AddRange(Table1.Rows.Count, 1); System.Drawing.Rectangle rect2 = new System.Drawing.Rectangle(0, Table1.Rows.Count - 1, Table1.Columns.Count - 2, 0); Table1.Merge(rect2); Table1[Table1.Rows.Count - 1, 0].TextHeight = 5; Table1[Table1.Rows.Count - 1, 0].Value = ":"; String SummStartCell = Table1[2, Table1.Columns.Count - 1].AddressOfCell(); String SummEndCell = Table1[Table1.Rows.Count - 2, Table1.Columns.Count - 1].AddressOfCell(); Table1[Table1.Rows.Count - 1, Table1.Columns.Count - 1].ValueFormula = "=summ(" + SummStartCell + ":" + SummEndCell + ")";
OnEdit()
method OnEdit()
table object.Auto
, which allows you to automatically determine the type of data.Table.DbEntity.AddToCurrentDocument();
- adds a table primitive to the drawing, the coordinates of the upper left corner of the table coincide with the origin.Table.PlaceObject();
- interactive object insertion. The user will be prompted to define the table insertion point. Depending on the values ​​of the arguments, insertion can be performed with a preliminary call to the table editor. Calling the method without arguments, as well as with the value McEntity.PlaceFlags.Normal
will call the table editor. Table1.PlaceObject(McEntity.PlaceFlags.Silent);
McTable.InsertSubtable(ref McTable inTable, int row, int col, InsertionModeEnum mode);
inTable
- the table to be insertedrow, col
is the row and column number of the cell to insert into,mode
- insert table mode.InSingleCell
- the table will be inserted into a separate cell. The structure of the resulting table will be changed in accordance with the structure of the inserted table.CellByCell
- the table will be inserted “cell into cell”, starting with the top left. The resulting table will contain those cells that are common to the structures of both tables.Over
- the table will be inserted over. The cell sizes of both tables do not change. Table1.InsertSubtable(ProfileTable1, 1, 1, InsertionModeEnum.InSingleCell);
EmbedBlock()
method of the Cell
class, which allows you to embed a block in a separate cell, specifying the block ID, its name or the block name and the name of the file that contains it:bool EmbedBlock(int row, int col, McObjectId Id);
bool EmbedBlock(int row, int col, ref String name);
bool EmbedBlock(int row, int col, ref String name, ref String fileName);
Table1[1, 0].Value = " "; Table1[1, 2].EmbedBlock("Profile_03", "C:\\Profiles.dwg");
String object = Table1.AttachObject(polyline.ID); Table1[0, 0].ValueFormula = object + ".\"Geometry.Area\"";
Source: https://habr.com/ru/post/198774/
All Articles