# DataGridViewCellStyle

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (2.5.0.0)

Represents the formatting and style information applied to individual cells within a [DataGridView](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview) control.

{% tabs %}
{% tab title="C#" %}

```csharp
public class DataGridViewCellStyle : ICloneable, IHasPropertyStore, IDisposable
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DataGridViewCellStyle
    Inherits ICloneable
    Implements IHasPropertyStore, IDisposable
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)DataGridViewCellStyle()

Initializes a new instance of the [DataGridViewCellStyle](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle) class using default property values.

## Properties

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Alignment

[DataGridViewContentAlignment](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcontentalignment): Returns or sets a value indicating the position of the cell content within a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)BackColor

[Color](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.color): Returns or sets the background color of a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)BackgroundImage

[Image](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image): Returns or sets the background image displayed in a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)BackgroundImageAlign

[ContentAlignment](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.contentalignment): Returns or sets the background image alignment as defined in the [ContentAlignment](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle) enumeration.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)BackgroundImageLayout

[ImageLayout](https://docs.wisej.com/api/v2.5/wisej.web/enumerations/wisej.web.imagelayout): Returns or sets the background image layout as defined in the [ImageLayout](https://docs.wisej.com/api/v2.5/wisej.web/enumerations/wisej.web.imagelayout) enumeration.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)BackgroundImageSource

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the theme name or URL for the background image displayed in a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)ColSpan

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the number of columns that this cell can use to render its content.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception) The value is lower than 1 or greater than 100.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)CssClass

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets additional CSS class names to add to the [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell).

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)CssStyle

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the custom CSS styles to apply to the [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell).

You can use any CSS style string.

```csharp

  // add a double underline to the cell.
  this.dataGridView1[3, 4].Style.CssStyle = "border-bottom:2px solid black";

```

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)DataSourceNullValue

[Object](https://docs.microsoft.com/en-us/dotnet/api/system.object): Returns or sets the value saved to the data source when the user enters a null value into a cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Font

[Font](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.font): Returns or sets the font applied to the textual content of a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)ForeColor

[Color](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.color): Returns or sets the foreground color of a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Format

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the format string applied to the textual content of a [DataGridView](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview) cell.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)FormatProvider

[IFormatProvider](https://docs.microsoft.com/en-us/dotnet/api/system.iformatprovider): Returns or sets the object used to provide culture-specific formatting of [DataGridView](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview) cell values.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)IsDataSourceNullValueDefault

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns a value indicating whether the [DataSourceNullValue](#datasourcenullvalue) property has been set.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)IsFormatProviderDefault

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns a value that indicates whether the [FormatProvider](#formatprovider) property has been set.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)IsNullValueDefault

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Returns a value indicating whether the [NullValue](#nullvalue) property has been set.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)NullValue

[Object](https://docs.microsoft.com/en-us/dotnet/api/system.object): Returns or sets the [DataGridView](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview) cell display value corresponding to a cell value of [Value](https://docs.microsoft.com/en-us/dotnet/api/system.dbnull.value) or null.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Padding

[Padding](https://docs.wisej.com/api/v2.5/wisej.web/general/wisej.web.padding): Returns or sets the space between the edge of a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) and its content.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)RowSpan

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the number of rows that this cell can use to render its content.

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception) The value is lower than 1 or greater than 100.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Scope

[DataGridViewCellStyleScopes](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstylescopes): Returns the scope (the type of object) that owns the cell style.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Tag

[Object](https://docs.microsoft.com/en-us/dotnet/api/system.object): Returns or sets an object that contains additional data related to the [DataGridViewCellStyle](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle).

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)WrapMode

[DataGridViewTriState](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewtristate): Returns or sets whether textual content in a [DataGridViewCell](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell) cell is wrapped to subsequent lines or truncated when it is too long to fit on a single line.

## Methods

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Clone()

Creates an exact copy of this [DataGridViewCellStyle](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle).

**Returns:** [DataGridViewCellStyle](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle). A [DataGridViewCellStyle](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle) that represents an exact copy of this cell style.

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)Dispose()

Releases all resources used by the [DataGridViewCellStyle](https://docs.wisej.com/api/v2.5/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle).

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)ResetDataSourceNullValue()

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)ResetFormatProvider()

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)ResetNullValue()

### ![](https://314832588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MTHCfAYyBPycFG90wsw-4198400543%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media\&token=060b281d-9363-48a1-a0f9-788ad1831e96)ResetWrapMode()
