Draw a grid on a TPaintBox (Views: 29)
Problem/Question/Abstract: How to draw a grid on a TPaintBox Answer: procedure TForm1.DrawPaintBoxGrid(distance: Integer); var xpos, ypos: Integer; begin PaintBox1.Canvas.Brush.Color := clBlack; ypos := 0; xpos := 0; while ypos < PaintBox1.Height do begin ypos := ypos + distance; PaintBox1.Canvas.MoveTo(0, ypos); PaintBox1.Canvas.LineTo(PaintBox1.Width, ypos); while xpos < PaintBox1.Width do begin xpos := xpos + distance; PaintBox1.Canvas.MoveTo(xpos, 0); PaintBox1.Canvas.LineTo(xpos, PaintBox1.Height); end; end; end; |