Back to Devexpress

TextOptions.VAlignment Property

windowsforms-devexpress-dot-utils-dot-textoptions-04239392.md

latest7.6 KB
Original Source

TextOptions.VAlignment Property

Gets or sets the vertical alignment of text.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
[DefaultValue(VertAlignment.Default)]
[XtraSerializableProperty]
public virtual VertAlignment VAlignment { get; set; }
vb
<DefaultValue(VertAlignment.Default)>
<XtraSerializableProperty>
Public Overridable Property VAlignment As VertAlignment

Property Value

TypeDefaultDescription
VertAlignmentDefault

A VertAlignment value that specifies the text vertical alignment.

|

Available values:

NameDescription
Default

Places the text to its default position. The default position is in the center of an object.

| | Top |

Places the text to the top of an object.

| | Center |

Centers the text within an object.

| | Bottom |

Places the text to the bottom of an object.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to VAlignment
AppearanceObject

.TextOptions .VAlignment

| | TextOptions |

.DefaultOptions .VAlignment

| | TextOptions |

.DefaultOptionsCenteredWithEllipsis .VAlignment

| | TextOptions |

.DefaultOptionsMultiLine .VAlignment

| | TextOptions |

.DefaultOptionsNoWrap .VAlignment

| | TextOptions |

.DefaultOptionsNoWrapEx .VAlignment

|

Remarks

When an AppearanceObject’s style setting (for example, BackColor , ForeColor , Font and TextOptions.HAlignment ) is set to a non-default value, the corresponding Options.Use… option (for instance, Options.UseBackColor , Options.UseForeColor , Options.UseFont and Options.UseTextOptions ) is automatically set to true in the following cases:

  • The AppearanceObject belongs to a control/component (or its element), and this control/component has been completely loaded (see the control’s IsLoading property to check the load status);
  • The AppearanceObject belongs to a grid column/band or tree list column/band, and the column/band belongs to a grid/tree list control;
  • The AppearanceObject is standalone, that is, it does not belong to any control or component.

In other cases, the Options.Use… options are not automatically enabled. You may need to enable these options manually for the style settings to be in effect.

The following code snippets (auto-collected from DevExpress Examples) contain references to the VAlignment property.

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-mvvm-best-practices/CS/EventToCommandBehaviorParametersConverters/PassingParametersToCommandsUserControl.cs#L27

csharp
label.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
label.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
label.Parent = panel;

winforms-grid-copy-cells-in-biff8-format-using-excel-export-api/CS/gridCopyToClipboardExample/CopyToClipboardHelper.cs#L74

csharp
WrapText = appearance.TextOptions.WordWrap.HasFlag(WordWrap.Wrap),
VerticalAlignment = ConvertAlignment(appearance.TextOptions.VAlignment),
HorizontalAlignment = ConvertAlignment(appearance.TextOptions.HAlignment)

winforms-dashboard-get-underlying-data-for-clicked-item/CS/Dashboard_UnderlyingDataWin/Form1.cs#L33

csharp
lbl.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
lbl.Appearance.TextOptions.VAlignment = VertAlignment.Center;
lbl.Dock = DockStyle.Fill;

winforms-mvvm-best-practices/VB/EventToCommandBehaviorParametersConverters/PassingParametersToCommandsUserControl.vb#L27

vb
label.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center
label.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center
label.Parent = panel

winforms-grid-copy-cells-in-biff8-format-using-excel-export-api/VB/gridCopyToClipboardExample/CopyToClipboardHelper.vb#L72

vb
' Apply alignment
Dim alignment As XlCellAlignment = New XlCellAlignment() With {.WrapText = appearance.TextOptions.WordWrap.HasFlag(WordWrap.Wrap), .VerticalAlignment = ConvertAlignment(appearance.TextOptions.VAlignment), .HorizontalAlignment = ConvertAlignment(appearance.TextOptions.HAlignment)}
cell.ApplyFormatting(alignment)

winforms-dashboard-get-underlying-data-for-clicked-item/VB/Dashboard_UnderlyingDataWin/Form1.vb#L26

vb
lbl.Appearance.TextOptions.HAlignment = HorzAlignment.Center
lbl.Appearance.TextOptions.VAlignment = VertAlignment.Center
lbl.Dock = DockStyle.Fill

See Also

HAlignment

Trimming

WordWrap

TextOptions Class

TextOptions Members

DevExpress.Utils Namespace