DataGridColumnStyle.Alignment Property

Definition

Gets or sets the alignment of text in a column.

C#
public virtual System.Windows.Forms.HorizontalAlignment Alignment { get; set; }

Property Value

One of the HorizontalAlignment values. The default is Left. Valid options include Left, Center, and Right.

Examples

The following code example sets the Alignment property for each column in a System.Windows.Forms.DataGrid to HorizontalAlignment.Center if the data isn't a string.

VB
Private Sub SetAlign()
   Dim myColumnStyle As DataGridColumnStyle 
   For each myColumnStyle In dataGrid1.TableStyles("Customers"). _
   GridColumnStyles
      myColumnStyle.Alignment = HorizontalAlignment.Center
   Next
End Sub

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 10