TableCells Class
Contains members that allow you to manage cells in a row.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public class TableCells :
ReadOnlyList<TableCell>
Related API Members
The following members return TableCells objects:
Remarks
A Table consists of cells combined into rows. The Rows property stores all table rows. A row stores its cells in the Cells property. Call the InsertAsync/RemoveAsync method to add/remove a cell to/from the row. Perform this action for each table row to add or remove a table column.
The following example removes an existing column and adds two new columns to a table:
<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();
// Creates a table
Table firstTable = await richEdit.DocumentAPI.Tables.CreateAsync(0, columnCount, rowCount);
for (int i = rowCount-1; i >=0 ; i--)
for (int j = columnCount-1; j >=0 ; j--) {
var cellPosition = firstTable.Rows[i].Cells[j].Interval.Start;
await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
}
foreach (TableRow row in firstTable.Rows) {
// Removes the first cell
await row.Cells.RemoveAsync(0);
// Inserts a cell to the left of the first cell
await row.Cells.InsertAsync(0);
// Inserts a cell to the right of the last cell
await row.Cells.InsertAsync(row.Cells.Count - 1, true);
}
richEdit.DocumentAPI.EndUpdate();
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
}
Implements
See Also