DataGridViewContentAlignment Enumeration

 

Defines constants that indicate the alignment of content within a DataGridView cell.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public enum DataGridViewContentAlignment

Member nameDescription
BottomCenter

The content is aligned vertically at the bottom and horizontally at the center of a cell.

BottomLeft

The content is aligned vertically at the bottom and horizontally at the left of a cell.

BottomRight

The content is aligned vertically at the bottom and horizontally at the right of a cell.

MiddleCenter

The content is aligned at the vertical and horizontal center of a cell.

MiddleLeft

The content is aligned vertically at the middle and horizontally at the left of a cell.

MiddleRight

The content is aligned vertically at the middle and horizontally at the right of a cell.

NotSet

The alignment is not set.

TopCenter

The content is aligned vertically at the top and horizontally at the center of a cell.

TopLeft

The content is aligned vertically at the top and horizontally at the left of a cell.

TopRight

The content is aligned vertically at the top and horizontally at the right of a cell.

This enumeration is used by the DataGridViewCellStyle.Alignment property.

The following code example illustrates the use of this type. For more information, see How to: Format Data in the Windows Forms DataGridView Control.

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

.NET Framework
Available since 2.0
Return to top
Show: