vs2005下Graphics的使用

Swear_fling 2010-10-23 11:09:24
我想用Graphics类画图,但是,Graphics类库中不包含DrawLine()方法,怎样才能添加进去呢?请大家帮帮忙
...全文
98 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyuanmei 2010-10-25
  • 打赏
  • 举报
回复
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 绘制直线
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Graphics line = this.CreateGraphics();
line.DrawLine(Pens.Red,20,80,100,80);
line.DrawLine(Pens.Red,60,-80,60,120);
}
}
}
要在窗体里才能用graphics绘图
wuyq11 2010-10-24
  • 打赏
  • 举报
回复
Pen p = new Pen(Color.Blue, 5);//设置笔的粗细为,颜色为蓝色
Graphics g = this.CreateGraphics();
//画虚线
p.DashStyle = DashStyle.Dot;//定义虚线的样式为点
g.DrawLine(p, 10, 10, 200, 10);
//自定义虚线
p.DashPattern = new float[] { 2, 1 };//设置短划线和空白部分的数组
g.DrawLine(p, 10, 20, 200, 20);

g.Dispose();
p.Dispose();
哥子谭 2010-10-24
  • 打赏
  • 举报
回复
你上msdn上看看graphics的各个属性和方法
周药师 2010-10-23
  • 打赏
  • 举报
回复
“Graphics类库中不包含DrawLine()方法,”
包含有的

http://msdn.microsoft.com/zh-cn/library/xckcwxsa(v=VS.80).aspx
如一宝宝 2010-10-23
  • 打赏
  • 举报
回复
参考CSDN


System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.DrawLine(myPen, 0, 0, 200, 200);
myPen.Dispose();
formGraphics.Dispose();

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧