Draw Grid on the windows form using vb.net

 
You can draw a grid of one-pixel dots with the specified spacing, within the specified bounds, on the specified graphics surface, and in the specified color with the help of ControlPaint.DrawGrid Method using vb.net

You can use ControlPaint.DrawGrid Method like as :

Public Shared Sub DrawGrid ( grp As Graphics,area As Rectangle, _
pixelsBetweenDots As Size, backColor As Color )

Example

Following example draw a grid on windows form:

Private Sub Form1_Paint(ByVal sender As System.Object, _
                            ByVal e As System.Windows.Forms.PaintEventArgs) _
                            Handles MyBase.Paint
        ControlPaint.DrawGrid(e.Graphics, New Rectangle(50, 200, 250, 100), New Size(5, 5), Color.Red)
End Sub

One thought on “Draw Grid on the windows form using vb.net”

Comments are closed.