blazor-devexpress-dot-blazor-dot-richedit-2d324236.md
A table in a sub-document.
Namespace : DevExpress.Blazor.RichEdit
Assembly : DevExpress.Blazor.RichEdit.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public class Table :
DocumentElementBase,
ITableProperties,
IIndexBasedTransactionalObject,
ITransactableObject
The following members return Table objects:
The Tables property returns the collection of tables in the sub-document. A table consists of cells combined into rows.
Tip
Refer to the following topic for examples on how to manage tables in code: Tables in Blazor Rich Text Editor.
The following code sample creates a table and populates it with data:
<DxRichEdit @ref="richEdit" />
@code {
DxRichEdit richEdit;
protected override async Task OnAfterRenderAsync(bool firstRender) {
if (firstRender)
try {
await InitializeDocument();
}
catch (TaskCanceledException) { }
await base.OnAfterRenderAsync(firstRender);
}
async Task InitializeDocument() {
/* Surround the code that contains an asynchronous operation with a try-catch block to handle
the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
try {
var columnCount = 4;
var rowCount = 5;
richEdit.DocumentAPI.BeginUpdate();
Table firstTable = await richEdit.DocumentAPI.Tables.CreateAsync(0, columnCount, rowCount);
for (int i = firstTable.Rows.Count - 1; i >= 0 ; i--)
for (int j = firstTable.Rows[i].Cells.Count - 1; j >= 0 ; j--) {
var cellPosition = myTable.Rows[i].Cells[j].Interval.Start;
await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
}
richEdit.DocumentAPI.EndUpdate();
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
}
The Rich Text Editor includes the following dialogs that allow users to create, edit, and delete tables.
The Rich Text Editor invokes this dialog when a user selects the Insert → Table ribbon command. The Insert Table dialog allows users to create a table with a specified number of rows and columns.
The Rich Text Editor invokes this dialog when a user selects the Insert → Insert Cells… context menu command. The Insert Cells dialog allows users to insert a cell, column, or row to a table.
The Rich Text Editor invokes this dialog when a user selects the Layout → Split Cells ribbon command or Split Cells… context menu command. The Split Cells dialog allows users to split selected cells into multiple new cells.
The Rich Text Editor invokes this dialog when a user selects the Layout → Delete → Delete Cells… ribbon command or Delete Cells… context menu command. The Delete Cells dialog allows users to delete a table cell, column, or row.
Object DevExpress.Blazor.RichEdit.Internal.DocumentObject DocumentElementBase Table
See Also