This documentation is archived and is not being maintained.

DataGridViewCellStyle Class

Note: This class is new in the .NET Framework version 2.0.

Represents the formatting and style information applied to individual cells within a DataGridView control.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public ref class DataGridViewCellStyle : ICloneable
public class DataGridViewCellStyle implements ICloneable
public class DataGridViewCellStyle implements ICloneable

The DataGridViewCellStyle class lets you share style information across multiple DataGridView cells, rows, columns, and row or column headers, avoiding the memory requirements of setting style properties on individual cells. For more information about classes that have a property of type DataGridViewCellStyle and how they relate to each other, see Cell Styles in the Windows Forms DataGridView Control.

The following code example demonstrates the effect of setting properties on multiple DataGridViewCellStyle objects. This example sets the background color of cells in the DataGridView by setting the BackColor property on the DefaultCellStyle property. The background color is overridden on alternating rows because the BackColor property is set on the AlternatingRowsDefaultCellStyle property. The example also determines the format of dates in the column named Last Prepared by setting the Format property on the column's DefaultCellStyle property.

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

System.Object
  System.Windows.Forms.DataGridViewCellStyle

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Show: