按照下面代码出现了这种情况
请问为什么画图会超出边界啊,应该是刚刚好才对。
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
int x1 = pictureBox1.Location.X;
int x2 = pictureBox1.Location.X + pictureBox1.Size.Width / 2;
int x3 = pictureBox1.Location.X + pictureBox1.Size.Width;
int y1 = pictureBox1.Location.Y;
int y2 = pictureBox1.Location.Y + pictureBox1.Size.Height / 2;
int y3 = pictureBox1.Location.Y + pictureBox1.Size.Height;
Pen p = new Pen(Color.Red, 1);
g.DrawLine(p, new Point(x1, y1), new Point(x3, y1));
g.DrawLine(p, new Point(x1, y2), new Point(x3, y2));
g.DrawLine(p, new Point(x1, y3), new Point(x3, y3));
g.DrawLine(p, new Point(x1, y1), new Point(x1, y3));
g.DrawLine(p, new Point(x2, y1), new Point(x2, y3));
g.DrawLine(p, new Point(x3, y1), new Point(x3, y3));
}