DataGridViewBand.DefaultCellStyle Property
.NET Framework (current version)
Gets or sets the default cell style of the band.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
<BrowsableAttribute(False)> Public Overridable Property DefaultCellStyle As DataGridViewCellStyle
Property Value
Type: System.Windows.Forms.DataGridViewCellStyleThe 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 Sub Button4_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Button4.Click FreezeBand(dataGridView.Rows(0)) End Sub Private Sub FreezeColumn(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Button5.Click FreezeBand(dataGridView.Columns(1)) End Sub Private Shared Sub FreezeBand(ByVal band As DataGridViewBand) band.Frozen = True Dim style As DataGridViewCellStyle = New DataGridViewCellStyle() style.BackColor = Color.WhiteSmoke band.DefaultCellStyle = style End Sub
.NET Framework
Available since 2.0
Available since 2.0
Show: