Edit

Share via


DataGridViewCellStyle.Alignment Property

Definition

Gets or sets a value indicating the position of the cell content within a DataGridView cell.

public System.Windows.Forms.DataGridViewContentAlignment Alignment { get; set; }

Property Value

One of the DataGridViewContentAlignment values. The default is NotSet.

Exceptions

The property value is not a valid DataGridViewContentAlignment value.

Examples

The following code example illustrates the use of this property.

this.dataGridView1.Columns["CustomerName"].DefaultCellStyle
    .Alignment = DataGridViewContentAlignment.MiddleRight;

Applies to

Product Versions
.NET Framework 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, 3.1, 5, 6, 7, 8, 9, 10

See also