officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-tablecollection-dot-create-x28-documentposition-int32-int32-autofitbehaviortype-x29.md
Inserts a blank table with the specified number of rows and columns at the specified position.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
Table Create(
DocumentPosition pos,
int rowCount,
int columnCount,
AutoFitBehaviorType autoFitBehavior
)
Function Create(
pos As DocumentPosition,
rowCount As Integer,
columnCount As Integer,
autoFitBehavior As AutoFitBehaviorType
) As Table
| Name | Type | Description |
|---|---|---|
| pos | DocumentPosition |
A DocumentPosition at which a table is inserted.
| | rowCount | Int32 |
A number of table rows.
| | columnCount | Int32 |
A number of table columns.
| | autoFitBehavior | AutoFitBehaviorType |
Indicates the AutoFit layout algorithm type.
|
| Type | Description |
|---|---|
| Table |
The newly created table.
|
The inserted table’s text direction depends on the RightToLeft property value of a paragraph where the table should be inserted. If the paragraph’s RightToLeft property is set to true, the table’s RightToLeft property is automatically set to true. The RightToLeft property of all cell paragraphs is also set to true.
Use the ReadOnlyParagraphCollection.Get(DocumentPosition) method to obtain the paragraph that contains the DocumentPosition.
When you call the Create method to insert a new table right before or after the existing table, these tables are merged and the Create method returns the resulting table. Successive tables with different directions are not merged.
Set the RichEditControlCompatibility.MergeSuccessiveTables property to false to keep successive tables with the same direction separate.
The following code snippets (auto-collected from DevExpress Examples) contain references to the Create(DocumentPosition, Int32, Int32, AutoFitBehaviorType) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Table.cs#L15
// Insert new table.
Table tbl = document.Tables.Create(document.Range.Start, 1, 3, AutoFitBehaviorType.AutoFitToWindow);
// Create a table header.
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/TableActions.cs#L19
// Insert new table.
Table tbl = document.Tables.Create(document.Range.Start, 1, 3, AutoFitBehaviorType.AutoFitToWindow);
// Create a table header.
word-document-api-examples/CS/CodeExamples/TablesActions.cs#L112
// Create a table with three rows and five columns at the document range's start position.
Table table = document.Tables.Create(document.Range.Start, 3, 5, AutoFitBehaviorType.AutoFitToWindow);
winforms-richedit-customize-popup-menu/CS/RichEditContextMenu/Form1.cs#L22
richEditControl.Document.AppendText("Table Test\r\n");
Table table = richEditControl.Document.Tables.Create(richEditControl.Document.Paragraphs[1].Range.Start, 8, 8, AutoFitBehaviorType.AutoFitToWindow);
{
DevExpress.XtraRichEdit.API.Native.Table table = document.Tables.Create(document.Range.End, rowsCount + 1, columnsCount, AutoFitBehaviorType.FixedColumnWidth);
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Table.vb#L14
' Insert new table.
Dim tbl As DevExpress.XtraRichEdit.API.Native.Table = document.Tables.Create(document.Range.Start, 1, 3, DevExpress.XtraRichEdit.API.Native.AutoFitBehaviorType.AutoFitToWindow)
' Create a table header.
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/TableActions.vb#L16
' Insert new table.
Dim tbl As Table = document.Tables.Create(document.Range.Start, 1, 3, AutoFitBehaviorType.AutoFitToWindow)
' Create a table header.
word-document-api-examples/VB/CodeExamples/TablesActions.vb#L39
' Insert a new table with one row and three columns at the document range's start position.
Dim tbl As DevExpress.XtraRichEdit.API.Native.Table = document.Tables.Create(document.Range.Start, 1, 3, DevExpress.XtraRichEdit.API.Native.AutoFitBehaviorType.AutoFitToWindow)
' Create a table header.
winforms-richedit-customize-popup-menu/VB/RichEditContextMenu/Form1.vb#L21
richEditControl.Document.AppendText("Table Test" & ControlChars.CrLf)
Dim table As Table = richEditControl.Document.Tables.Create(richEditControl.Document.Paragraphs(1).Range.Start, 8, 8, AutoFitBehaviorType.AutoFitToWindow)
word-document-api-invoke-print-preview-dialog/VB/Form1.vb#L34
richServer.BeginUpdate()
Dim _table As Table = richServer.Document.Tables.Create(richServer.Document.Selection.Start, 8, 8, AutoFitBehaviorType.FixedColumnWidth)
_table.BeginUpdate()
See Also