DefaultCellStyle Property
TOC
Collapse the table of content
Expand the table of content

DataGridView::DefaultCellStyle Property

 

Gets or sets the default cell style to be applied to the cells in the DataGridView if no other cell style properties are set.

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

public:
property DataGridViewCellStyle^ DefaultCellStyle {
	DataGridViewCellStyle^ get();
	void set(DataGridViewCellStyle^ value);
}

Property Value

Type: System.Windows.Forms::DataGridViewCellStyle^

The DataGridViewCellStyle to be applied as the default style.

The DataGridView control displays its cells using the styles indicated by the cell InheritedStyle property, which inherits styles from other properties of type DataGridViewCellStyle. The styles specified through the DefaultCellStyle property affect all cells except when overridden by the styles specified through the following properties:

For more information, see Cell Styles in the Windows Forms DataGridView Control.

When getting this property, a DataGridViewCellStyle with default values will be created if the property has not already been accessed. This can cause a performance impact when getting this property for many rows. Whenever possible, use a single DataGridViewCellStyle to set this property for multiple rows. For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.

The following code example illustrates the use of this property in a DataGridView control intended primarily for display. In this example, the visual appearance of the control is customized in several ways and the control is configured for limited interactivity. This example is part of a larger example available in the DataGridViewCellStyle class overview.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft