C# 2.0 在Picturebox绘制 网格线
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Roading001
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
drawGrids(e);
}
private void drawGrids(PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen myPen = Pens.Blue;
for (int i = 0; i < ClientRectangle.Width; i++)
{
g.DrawLine(myPen, new Point(i, 0), new Point(i, ClientRectangle.Bottom));
i += 10;
}
for (int j = 0; j < ClientRectangle.Height; j++)
{
g.DrawLine(myPen, new Point(0, j), new Point(ClientRectangle.Right, j));
j += 10;
}
}
}
}

浙公网安备 33010602011771号