This documentation is archived and is not being maintained.

DataGridViewBand.DefaultCellStyle Property

Gets or sets the default cell style of the band.

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

public virtual DataGridViewCellStyle DefaultCellStyle { get; set; }
/** @property */
public DataGridViewCellStyle get_DefaultCellStyle ()

/** @property */
public void set_DefaultCellStyle (DataGridViewCellStyle value)

public function get DefaultCellStyle () : DataGridViewCellStyle

public function set DefaultCellStyle (value : DataGridViewCellStyle)

Not applicable.

Property Value

The DataGridViewCellStyle associated with the DataGridViewBand.

The default cell style is applied to cells that do not have an associated style. When getting this property, a DataGridViewCellStyle with default values will be created if the default cell style does not exist.

The following code example sets the default cell style for the first column in a DataGridView.

// Freeze the first row.
private void Button4_Click(object sender, System.EventArgs e)


private void Button5_Click(object sender, System.EventArgs e)


private static void FreezeBand(DataGridViewBand band)
    band.Frozen = true;
    DataGridViewCellStyle style = new DataGridViewCellStyle();
    style.BackColor = Color.WhiteSmoke;
    band.DefaultCellStyle = style;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0