This documentation is archived and is not being maintained.

DataGridViewButtonColumn.DefaultCellStyle Property

Gets or sets the column's default cell style.

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

public override DataGridViewCellStyle DefaultCellStyle { get; set; }

Property Value

Type: System.Windows.Forms.DataGridViewCellStyle
The DataGridViewCellStyle to be applied as the default style.

The default DataGridViewCellStyle returned by this property has an initial Alignment property value of MiddleCenter. This value overrides the value specified in the DefaultCellStyle property of the DataGridView control, but may be overridden by other cell style properties. For more information, see Cell Styles in the Windows Forms DataGridView Control.


When visual styles are enabled, the buttons in a button column are painted using a ButtonRenderer and cell styles specified through properties such as DefaultCellStyle have no effect.

The following code example demonstrates the use of this property.

private void ChangeColumnAlignment()
    songsDataGridView.Columns["Title"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
    songsDataGridView.Columns["Title"].Name = DataGridViewContentAlignment.BottomCenter.ToString();

    songsDataGridView.Columns["Artist"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft;
    songsDataGridView.Columns["Artist"].Name = DataGridViewContentAlignment.BottomLeft.ToString();

    songsDataGridView.Columns["Album"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
    songsDataGridView.Columns["Album"].Name = DataGridViewContentAlignment.BottomRight.ToString();

    songsDataGridView.Columns["Release Date"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
    songsDataGridView.Columns["Release Date"].Name = DataGridViewContentAlignment.MiddleCenter.ToString();

    songsDataGridView.Columns["Track"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
    songsDataGridView.Columns["Track"].Name = DataGridViewContentAlignment.MiddleLeft.ToString();

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.