DataGridViewCellBorderStyle Enum

Definition

Specifies the border styles that can be applied to the cells of a DataGridView control.

public enum DataGridViewCellBorderStyle
Inheritance
DataGridViewCellBorderStyle

Fields

Name Value Description
Custom 0

A border that has been customized.

Single 1

A single line border.

Raised 2

A three-dimensional raised border.

Sunken 3

A three-dimensional sunken border.

None 4

No borders.

SingleVertical 5

A vertical single-line border.

RaisedVertical 6

A vertical three-dimensional raised border.

SunkenVertical 7

A vertical three-dimensional sunken border.

SingleHorizontal 8

A horizontal single-line border.

RaisedHorizontal 9

A horizontal three-dimensional raised border.

SunkenHorizontal 10

A horizontal three-dimensional sunken border.

Examples

The following code example illustrates the use of this type.

private void SetBorderAndGridlineStyles()
{
    this.dataGridView1.GridColor = Color.BlueViolet;
    this.dataGridView1.BorderStyle = BorderStyle.Fixed3D;
    this.dataGridView1.CellBorderStyle =
        DataGridViewCellBorderStyle.None;
    this.dataGridView1.RowHeadersBorderStyle =
        DataGridViewHeaderBorderStyle.Single;
    this.dataGridView1.ColumnHeadersBorderStyle =
        DataGridViewHeaderBorderStyle.Single;
}

Remarks

The CellBorderStyle property of the DataGridView control uses the DataGridViewCellBorderStyle enumeration. To draw borders only between the rows, specify SingleHorizontal, SunkenHorizontal or RaisedHorizontal. To draw borders only between the columns, specify SingleVertical, SunkenVertical or RaisedVertical. To draw borders between the rows and columns, specify SingleSunken or Raised.

Applies to

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also