using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace e1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //窗体的 paint 事件中 private void Form1_Paint(object sender, PaintEventArgs e) { Graphics gra = e.Graphics; gra.TranslateTransform(0.0F,0.0F);//划线的其实位置 gra.PageUnit = GraphicsUnit.Pixel;//单位 像素,厘米,英寸 等。。。 Pen pen = new Pen(Color.Blue, 1/100);//设置画笔 gra.DrawLine(pen, 0, 0, 145, 145);//绘制直线 } } }