Export (0) Print
Expand All
Expand Minimize

DataGridView.GridColor Property

Gets or sets the color of the grid lines separating the cells of the DataGridView.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member GridColor : Color with get, set

Property Value

Type: System.Drawing.Color
A Color or SystemColors that represents the color of the grid lines. The default is ControlDarkDark.

ExceptionCondition
ArgumentException

The specified value when setting this property is Empty.

-or-

The specified value when setting this property has a Color.A property value that is less that 255.

You can set the GridColor property to any color when you use a single border; with other types of borders, the colors are specified by the operating system. If visual styles are enabled for the application through the Application.EnableVisualStyles method, the GridColor property is ignored, and the current theme's colors are used.

The following code example demonstrates how to set the ColumnHeadersDefaultCellStyle, AutoSizeRowsMode, ColumnHeadersBorderStyle, CellBorderStyle, GridColor, BackgroundColor, RowHeadersVisible, SelectionMode, ColumnCount, and MultiSelect properties. In addition, the code example demonstrates how to set the DataGridViewColumn.Name and DataGridViewColumn.DefaultCellStyle properties. To run this example, paste the code into a form that contains a DataGridView named dataGridView1, and then call the SetUpDataGridView method from the form's constructor or Load event handler. Ensure all events are associated with their event handlers.

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

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft