private void button1_Click(object sender, EventArgs e)
{
//this代表当前窗体,在当前窗体上创建Graphics
//第一步:创建GDI对象
Graphics g = this.CreateGraphics();
//创建一个画笔
Pen p=new Pen (Color.Red,2);
//确定两个点
Point p1 = new Point(20, 20);
Point p2 = new Point(30, 40);
//调用GDI的DrawLine方法
g.DrawLine(p, p1, p2);
}
时间: 2024-12-18 11:39:39