ControlPaint.DrawGrid(Graphics, Rectangle, Size, Color) Method

Definition

Draws a grid of one-pixel dots with the specified spacing, within the specified bounds, on the specified graphics surface, and in the specified color.

C#
public static void DrawGrid(System.Drawing.Graphics graphics, System.Drawing.Rectangle area, System.Drawing.Size pixelsBetweenDots, System.Drawing.Color backColor);

Parameters

graphics
Graphics

The Graphics to draw on.

area
Rectangle

The Rectangle that represents the dimensions of the grid.

pixelsBetweenDots
Size

The Size that specified the height and width between the dots of the grid.

backColor
Color

The Color of the background behind the grid.

Remarks

The backColor parameter is used to calculate the fill color of the dots so that the grid is always visible against the background.

Applies to

Product Versions
.NET Framework 1.1, 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