# DataGridViewCellStyle

Namespace: **Wisej.Web**

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

Represents the formatting and style information applied to individual cells within a [DataGridView](/api/wisej.web/lists-and-grids/datagridview.md) 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

### ![](/files/hsR4ok3152WyAf8J2C1u) DataGridViewCellStyle()

Initializes a new instance of the [DataGridViewCellStyle](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle.md) class using default property values.

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) Alignment

[DataGridViewContentAlignment](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcontentalignment.md): Returns or sets a value indicating the position of the cell content within a [DataGridViewCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) cell. (Default: `NotSet`)

### ![](/files/hsR4ok3152WyAf8J2C1u) BackColor

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

### ![](/files/hsR4ok3152WyAf8J2C1u) BackgroundImage

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

### ![](/files/hsR4ok3152WyAf8J2C1u) BackgroundImageAlign

[ContentAlignment](https://docs.microsoft.com/dotnet/api/system.drawing.contentalignment): Returns or sets the background image alignment as defined in the [ContentAlignment](https://docs.microsoft.com/dotnet/api/system.drawing.contentalignment) enumeration. (Default: `MiddleLeft`)

### ![](/files/hsR4ok3152WyAf8J2C1u) BackgroundImageLayout

[ImageLayout](/api/wisej.web/enumerations/wisej.web.imagelayout.md): Returns or sets the background image layout as defined in the [ImageLayout](/api/wisej.web/enumerations/wisej.web.imagelayout.md) enumeration. (Default: `None`)

### ![](/files/hsR4ok3152WyAf8J2C1u) BackgroundImageSource

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

### ![](/files/hsR4ok3152WyAf8J2C1u) ColSpan

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

**Throws:**

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

### ![](/files/hsR4ok3152WyAf8J2C1u) CssClass

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

### ![](/files/hsR4ok3152WyAf8J2C1u) CssStyle

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

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";


```

### ![](/files/hsR4ok3152WyAf8J2C1u) DataSourceNullValue

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Font

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

### ![](/files/hsR4ok3152WyAf8J2C1u) ForeColor

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Format

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

### ![](/files/hsR4ok3152WyAf8J2C1u) FormatProvider

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

### ![](/files/hsR4ok3152WyAf8J2C1u) IsDataSourceNullValueDefault

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

### ![](/files/hsR4ok3152WyAf8J2C1u) IsFormatProviderDefault

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

### ![](/files/hsR4ok3152WyAf8J2C1u) IsNullValueDefault

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

### ![](/files/hsR4ok3152WyAf8J2C1u) NullValue

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Padding

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

### ![](/files/hsR4ok3152WyAf8J2C1u) RowSpan

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

**Throws:**

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Scope

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Tag

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

### ![](/files/hsR4ok3152WyAf8J2C1u) WrapMode

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

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) Clone()

Creates an exact copy of this [DataGridViewCellStyle](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle.md).

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Dispose()

Releases all resources used by the [DataGridViewCellStyle](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle.md).

### ![](/files/lzopMboA31bVq8UIcbT3) Dispose(disposing)

Releases the resources used by the [DataGridViewCellStyle](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle.md).

| Parameter     | Type                                                            | Description                                                                 |
| ------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------- |
| **disposing** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true when this method is called by the application rather than a finalizer. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
