C# 新手: 如何在form上画一条横线,用那个控件?

zhicungao 2008-09-10 04:46:39
能设置线的颜色,粗细,不是在网页上
...全文
6377 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhicungao 2008-09-20
  • 打赏
  • 举报
回复
谢谢各位了,结贴去。
enaking 2008-09-11
  • 打赏
  • 举报
回复
最简单的办法是用pannel,,将高设为一个像素,,背景色为黑色就可以了
leehong0704 2008-09-11
  • 打赏
  • 举报
回复
GDI+ drawline的方法。
zt_100094 2008-09-11
  • 打赏
  • 举报
回复
Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(Color.Black,10.0f),new Point(10,10),new Point(100,10));
wangfeng8317 2008-09-11
  • 打赏
  • 举报
回复
我一般用GroupBox
天府荣城 2008-09-10
  • 打赏
  • 举报
回复
答案都已经出来了,
来顶一下。
hyblusea 2008-09-10
  • 打赏
  • 举报
回复
看来已经有答案了....纯顶.....
legendcyqkt 2008-09-10
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 gwqwyh 的回复:]

Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(Color.Black, 10.0f), new Point(10, 10), new Point(100, 10));
[/Quote]
修改成一个简单的.
Graphics g = this.CreateGraphics();
g.DrawLine(Pens.Black,10,10,10,10);线默认宽为1
jiguixin 2008-09-10
  • 打赏
  • 举报
回复
RichTextBox应该得行,我一般都是用这个
tianmingl 2008-09-10
  • 打赏
  • 举报
回复
更正一下,在panel中绘图:
Graphics g = graphPanel.CreateGraphics();
Pen p = new Pen(Color.Black, 2.0f);
g.DrawLine(p,xPlot1, yPlot1, xPlot2, yPlot2);



xPlot1, yPlot1是起始点的x,y坐标
xPlot2, yPlot2是终止点的坐标
程序yy 2008-09-10
  • 打赏
  • 举报
回复

Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(Color.Black, 10.0f), new Point(10, 10), new Point(100, 10));
程序yy 2008-09-10
  • 打赏
  • 举报
回复

Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(Color.Black, 10.0f), new Point(10, 10), new Point(100, 10));
Ki1381 2008-09-10
  • 打赏
  • 举报
回复
最简单的办法就是直接用个Lable,AutoSize = false, text = "",设置背景色,高度弄小一点,宽度看你需要,哈哈
shengyan19 2008-09-10
  • 打赏
  • 举报
回复
补充一点 划线的方法 要写在 窗体 重绘事件里面
LovingAlison 2008-09-10
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 gisfarmer 的回复:]
不用控件。直接可以绘制

Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(Color.Black,10.0f),new Point(10,10),new Point(100,10));
[/Quote]
niliqing 2008-09-10
  • 打赏
  • 举报
回复
pannel
java_303 2008-09-10
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 gisfarmer 的回复:]
不用控件。直接可以绘制

Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(Color.Black,10.0f),new Point(10,10),new Point(100,10));
[/Quote]
tianmingl 2008-09-10
  • 打赏
  • 举报
回复
在pannel上直接绘制,
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Black, 2.0f);
g.DrawLine(p,xPlot1, yPlot1, xPlot2, yPlot2);
ProjectDD 2008-09-10
  • 打赏
  • 举报
回复
LinkLabel
lude8880 2008-09-10
  • 打赏
  • 举报
回复
<br/>
加载更多回复(9)

111,080

社区成员

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

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

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