Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

DataGridViewCellStyle Class

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

System.Object
  System.Windows.Forms.DataGridViewCellStyle

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[<TypeConverterAttribute(typeof(DataGridViewCellStyleConverter))>]
type DataGridViewCellStyle =  
    class 
        interface ICloneable 
    end

The DataGridViewCellStyle type exposes the following members.

  NameDescription
Public methodDataGridViewCellStyle()Initializes a new instance of the DataGridViewCellStyle class using default property values.
Public methodDataGridViewCellStyle(DataGridViewCellStyle)Initializes a new instance of the DataGridViewCellStyle class using the property values of the specified DataGridViewCellStyle.
Top
  NameDescription
Public propertyAlignmentGets or sets a value indicating the position of the cell content within a DataGridView cell.
Public propertyBackColorGets or sets the background color of a DataGridView cell.
Public propertyDataSourceNullValueGets or sets the value saved to the data source when the user enters a null value into a cell.
Public propertyFontGets or sets the font applied to the textual content of a DataGridView cell.
Public propertyForeColorGets or sets the foreground color of a DataGridView cell.
Public propertyFormatGets or sets the format string applied to the textual content of a DataGridView cell.
Public propertyFormatProviderGets or sets the object used to provide culture-specific formatting of DataGridView cell values.
Public propertyIsDataSourceNullValueDefaultGets a value indicating whether the DataSourceNullValue property has been set.
Public propertyIsFormatProviderDefaultGets a value that indicates whether the FormatProvider property has been set.
Public propertyIsNullValueDefaultGets a value indicating whether the NullValue property has been set.
Public propertyNullValueGets or sets the DataGridView cell display value corresponding to a cell value of DBNull.Value or a null reference (Nothing in Visual Basic).
Public propertyPaddingGets or sets the space between the edge of a DataGridViewCell and its content.
Public propertySelectionBackColorGets or sets the background color used by a DataGridView cell when it is selected.
Public propertySelectionForeColorGets or sets the foreground color used by a DataGridView cell when it is selected.
Public propertyTagGets or sets an object that contains additional data related to the DataGridViewCellStyle.
Public propertyWrapModeGets or sets a value indicating whether textual content in a DataGridView cell is wrapped to subsequent lines or truncated when it is too long to fit on a single line.
Top
  NameDescription
Public methodApplyStyleApplies the specified DataGridViewCellStyle to the current DataGridViewCellStyle.
Public methodCloneCreates an exact copy of this DataGridViewCellStyle.
Public methodEqualsReturns a value indicating whether this instance is equivalent to the specified object. (Overrides Object.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Overrides Object.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string indicating the current property settings of the DataGridViewCellStyle. (Overrides Object.ToString().)
Top
  NameDescription
Explicit interface implemetationPrivate methodICloneable.CloneCreates an exact copy of this DataGridViewCellStyle.
Top

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.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.