'宣言 Public Property LabelTextAlignment As Nullable(Of TextAlignment)
public Nullable<TextAlignment> LabelTextAlignment {get; set;}
注: この設定は、Field の Label が文字列で、LabelPresenter の ContentTemplate プロパティが設定されていない場合にのみ適用されます。
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