码迷,mamicode.com
首页 > Windows程序 > 详细

C#画图

时间:2014-12-20 14:16:37      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:

画线

private void Form1_Load(object sender, EventArgs e)
{
this.Paint += new PaintEventHandler(Form1_Paint);
}

//画线
void Form1_Paint(object sender, PaintEventArgs e)
{

Pen blackPen = new Pen(Color.Black, 2);//创建画笔
Point point1;//起点坐标
Point point2;//终点坐标

int x=10;

int y=10;

int w=100;

int h=100;
point1 = new Point(x, y);
point2 = new Point(x, h);
e.Graphics.DrawLine(blackPen, point1, point2);//竖线
point1 = new Point(x, y);
point2 = new Point(w, y);
e.Graphics.DrawLine(blackPen, point1, point2);//横线

Brush brush = new SolidBrush(Color.Black);//字体颜色

   Font captionFontT = new Font("宋体", 14);//字体样式

e.Graphics.DrawString("显示内容", captionFontT, brush, x+10, y, StringFormat.GenericDefault);//画内容

}

C#画图

标签:

原文地址:http://www.cnblogs.com/yangdunqin/p/huaxian.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!