Table.TableStyleOptions Property
Returns style options applied to the table.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public TableStyleOptions TableStyleOptions { get; }
Property Value
Type | Description |
---|---|
TableStyleOptions | A set of table style options. |
Available values:
Name | Description |
---|---|
None | Applies no special formatting to columns and rows. |
HeaderRow | Applies special formatting to the first row. |
TotalRow | Applies special formatting to the last row. |
BandedRows | Applies special formatting to odd rows. |
FirstColumn | Applies special formatting to the first column. |
LastColumn | Applies special formatting to the last column. |
BandedColumns | Applies special formatting to odd columns. |
Remarks
Use a table’s TableStyleOptions
property to obtain style options applied to the table.
Note
Style options do not affect table appearance if the NormalTable
or GridTableLight
style is applied to the table.
Pass a TableProperties instance to the ChangePropertiesAsync method to customize table appearance. Assign a TableStyleName property to the TableProperties.StyleName property to apply a style to the table. Specify TableProperties.TableStyleOptions to apply/remove special formatting to/from the first, last, and odd columns and rows.
Set the TableProperties.TableStyleOptions property to None
to remove special formatting from all columns and rows. Note that the None
flag has no effect in combination with other flags. For instance, if TableProperties.TableStyleOptions is set to a combination of None
and FirstColumn
, the table displays special formatting for the first column.
The following example applies special formatting to odd table rows:
<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 myTable = 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 = myTable.Rows[i].Cells[j].Interval.Start;
await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
}
// Customizes the table
myTable = await richEdit.DocumentAPI.Tables.GetAsync(0);
if (!myTable.TableStyleOptions.HasFlag(TableStyleOptions.BandedRows))
await myTable.ChangePropertiesAsync(properties => {
properties.TableStyleOptions = properties.TableStyleOptions | TableStyleOptions.BandedRows;
});
richEdit.DocumentAPI.EndUpdate();
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
}