blazor-devexpress-dot-blazor-dot-richedit-dot-tablecellproperties-73b7c042.md
Specifies the vertical alignment of content in the cell.
Namespace : DevExpress.Blazor.RichEdit
Assembly : DevExpress.Blazor.RichEdit.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public VerticalAlignment ContentVerticalAlignment { get; set; }
| Type | Description |
|---|---|
| VerticalAlignment |
An enumeration value.
|
Available values:
| Name | Description |
|---|---|
| Top |
Aligns the items or text at the top.
| | Center |
Aligns the items or text at the center.
| | Bottom |
Aligns the items or text at the bottom.
|
The Rich Text Editor component allows you to specify a content vertical alignment for the following elements:
TableThe ContentVerticalAlignment property stores the vertical alignment of content in table cells. Call the ChangePropertiesAsync method and specify the TableProperties.ContentVerticalAlignment setting to vertically align content in all cells simultaneously.Table CellThe ContentVerticalAlignment property stores the vertical alignment of cell content. Call the ChangePropertiesAsync method and specify the TableCellProperties.ContentVerticalAlignment setting to vertically align cell content.
Note
A cell’s ContentVerticalAlignment property takes priority over the table’s ContentVerticalAlignment property.
The following example aligns content in table cells:
<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");
}
// Customizes the table
await firstTable.ChangePropertiesAsync(properties => {
properties.ContentHorizontalAlignment = HorizontalAlignment.Left;
properties.ContentVerticalAlignment = VerticalAlignment.Top;
properties.Width = new TableWidth(TableWidthType.Percent, 100);
});
foreach (TableRow row in firstTable.Rows)
await row.ChangePropertiesAsync(properties => {
properties.Height = new TableRowHeight(TableRowHeightType.Exact, 400);
});
foreach (TableCell cell in firstTable.Rows[0].Cells)
await cell.ChangePropertiesAsync(properties => {
properties.ContentHorizontalAlignment = HorizontalAlignment.Center;
properties.ContentVerticalAlignment = VerticalAlignment.Center;
});
richEdit.DocumentAPI.EndUpdate();
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
}
See Also