GetPosInParent() → { Number }
Возвращает позицию таблицы в ее родительском элементе.
Параметры:
Этот метод не имеет параметров.
Возвращает:
- Численный тип
Пример
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
var oRun = Api.CreateRun();
oRun.AddText("Number of paragraph elements at this point: ");
oRun.AddTabStop();
oRun.AddText("" + oParagraph.GetElementsCount());
oRun.AddLineBreak();
oParagraph.AddElement(oRun);
oRun.AddText("Number of paragraph elements after we added a text run: ");
oRun.AddTabStop();
oRun.AddText("" + oParagraph.GetElementsCount());
oDocument.AddElement(0, oParagraph);
var oTable = Api.CreateTable(3, 3);
oDocument.AddElement(0, oTable);
var nPosition = oTable.GetPosInParent();
oTable = oDocument.GetElement(nPosition);
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered"));
oTable.SetStyle(oTableStyle);
builder.SaveFile("docx", "GetPosInParent.docx");
builder.CloseFile();