This documentation is archived and is not being maintained.

DataGridColumnStyle.Alignment Property

Gets or sets the alignment of text in a column.

[Visual Basic]
Public Overridable Property Alignment As HorizontalAlignment
[C#]
public virtual HorizontalAlignment Alignment {get; set;}
[C++]
public: __property virtual HorizontalAlignment get_Alignment();
public: __property virtual void set_Alignment(HorizontalAlignment);
[JScript]
public function get Alignment() : HorizontalAlignment;
public function set Alignment(HorizontalAlignment);

Property Value

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

Example

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

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

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DataGridColumnStyle Class | DataGridColumnStyle Members | System.Windows.Forms Namespace

Show: