'Declaration Public Property LabelTextAlignment As Nullable(Of TextAlignment)
public Nullable<TextAlignment> LabelTextAlignment {get; set;}
Note: This setting only applies if the Field's Label is a string and the ContentTemplate property of LabelPresenter is not set.
public partial class Window2 : Window { public Window2() { InitializeComponent(); // Set the default label text alignment, trimming and wrapping settings this.XamDataGrid1.FieldSettings.LabelTextAlignment = TextAlignment.Left; this.XamDataGrid1.FieldSettings.LabelTextTrimming = TextTrimming.CharacterEllipsis; this.XamDataGrid1.FieldSettings.LabelTextWrapping = TextWrapping.Wrap; // wire up the FieldLayoutInitialized event to override the // text alignment based on the data type of the field this.XamDataGrid1.FieldLayoutInitialized += new EventHandler<Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs>(OnFieldLayoutInitialized); } void OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e) { foreach (Field field in e.FieldLayout.Fields) { // If the type is numeric then align the label on the right Type dataType = field.DataType; if (dataType == typeof(double) || dataType == typeof(float) || dataType == typeof(int) || dataType == typeof(decimal)) field.Settings.LabelTextAlignment = TextAlignment.Right; } } }
Imports Infragistics.Windows.DataPresenter Partial Public Class Window2 Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Set the default label text alignment, trimming and wrapping settings Me.XamDataGrid1.FieldSettings.LabelTextAlignment = TextAlignment.Left Me.XamDataGrid1.FieldSettings.LabelTextTrimming = TextTrimming.CharacterEllipsis Me.XamDataGrid1.FieldSettings.LabelTextWrapping = TextWrapping.Wrap End Sub Private Sub XamDataGrid1_FieldLayoutInitialized(ByVal sender As Object, ByVal e As Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs) Handles XamDataGrid1.FieldLayoutInitialized Dim datatype As Type For Each fld As Field In e.FieldLayout.Fields ' If the type is numeric then align the label on the right datatype = fld.DataType If (datatype Is GetType(Integer) OrElse _ datatype Is GetType(Double) OrElse _ datatype Is GetType(Single) OrElse _ datatype Is GetType(Decimal)) Then fld.Settings.LabelTextAlignment = TextAlignment.Right End If Next End Sub End Class
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2