How to: Set Font and Color Styles in the Windows Forms DataGridView Control
You can specify the visual appearance of cells within a DataGridView control by setting properties of the DataGridViewCellStyle class. You can retrieve instances of this class from various properties of the DataGridView class and its companion classes, or you can instantiate DataGridViewCellStyle objects for assignment to these properties.
The following procedures demonstrate basic customization of cell appearance using the DefaultCellStyle property. Every cell in the control inherits the styles specified through this property unless they are overridden at the column, row, or cell level. For an example of style inheritance, see How to: Set Default Cell Styles for the Windows Forms DataGridView Control. For information about additional uses of the DataGridViewCellStyle class, see the topics listed in the See Also section.
There is extensive support for this task in Visual Studio. Also see How to: Set Default Cell Styles and Data Formats for the Windows Forms DataGridView Control Using the Designer.
To specify the font used by DataGridView cells
To specify the foreground and background colors of DataGridView cells
To specify the foreground and background colors of selected DataGridView cells
Compiling the Code
For maximum scalability, you should share DataGridViewCellStyle objects across multiple rows, columns, or cells that use the same styles, rather than setting the style properties for each element separately. For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.