C# winform编程,怎么把label控件的长方形改成圆形,有什么方法可以?

wlkofwing 2006-04-23 01:19:28
具体方法是什么?才开始接触C#,请多多指教.
...全文
2225 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
兔子-顾问 2006-04-24
  • 打赏
  • 举报
回复
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Location = new System.Drawing.Point(48, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(176, 112);
this.label1.TabIndex = 0;
this.label1.Text = "\r\n\r\n TestMyLabel";
//调用的
兔子-顾问 2006-04-24
  • 打赏
  • 举报
回复
using System;

namespace 圆形label
{
/// <summary>
/// myArcLabel 的摘要说明。
/// </summary>
public class myEllipseLabel:System.Windows.Forms.Label
{
private System.Drawing.Pen _pen;
private int _PenWidth = 2;//线宽,描边的线的宽度
private System.Drawing.Rectangle EllipseRect;//边缘尺寸

public myEllipseLabel():base()
{
EllipseRect = new System.Drawing.Rectangle(0,0,150,150);
}

protected override void InitLayout()
{
System.Drawing.Drawing2D.GraphicsPath path =
new System.Drawing.Drawing2D.GraphicsPath();
path.AddEllipse(this.ClientRectangle);
EllipseRect = this.ClientRectangle;
EllipseRect.Width -= (_PenWidth + 1);
EllipseRect.Height -= (_PenWidth + 1);
this.Region = new System.Drawing.Region(path);
base.InitLayout ();
}

protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
{
base.OnPaintBackground (pevent);
if (_pen==null)
{
_pen = new System.Drawing.Pen(this.ForeColor,_PenWidth);
}
pevent.Graphics.DrawEllipse(_pen,EllipseRect);
}

}
}

//刚写了个类。貌似可以完成你的想法。设计的时候还可以改变尺寸。
-渔民- 2006-04-24
  • 打赏
  • 举报
回复
繪圖
叮当大雄 2006-04-24
  • 打赏
  • 举报
回复
up
wlkofwing 2006-04-24
  • 打赏
  • 举报
回复
怎么结帖?怎么找不到连接.郁闷
wlkofwing 2006-04-24
  • 打赏
  • 举报
回复
我提的这个问题是为了解决红绿灯小玩意的灯是圆的问题,已经做出来圆的灯了.当然方的很简单.
可以看看我画的圆作为红绿灯的灯.
连接http://community.csdn.net/Expert/topic/4707/4707165.xml?temp=.2129785
huangguangdou 2006-04-24
  • 打赏
  • 举报
回复
study
yf1025 2006-04-24
  • 打赏
  • 举报
回复
学习学习
WangJun_ 2006-04-24
  • 打赏
  • 举报
回复
搞的不错
Jamestan 2006-04-24
  • 打赏
  • 举报
回复
学习了
copico 2006-04-24
  • 打赏
  • 举报
回复
恭喜恭喜
wlkofwing 2006-04-24
  • 打赏
  • 举报
回复
谢谢.高手啊.做出来了.圆形的LABEL
代码:
http://community.csdn.net/Expert/topic/4707/4707165.xml?temp=.875149
star0796 2006-04-23
  • 打赏
  • 举报
回复
第一步:自定义一个控件继承于label
第二步:重写paint事件
webwalker 2006-04-23
  • 打赏
  • 举报
回复
继承、修改
gths123 2006-04-23
  • 打赏
  • 举报
回复
哈哈,没这么用过,帮顶一下
copico 2006-04-23
  • 打赏
  • 举报
回复
自己画圆
ipqn 2006-04-23
  • 打赏
  • 举报
回复
自带了好像不行,把Label放到Panel中吧,可以实现你所要的视觉效果!
jetxia 2006-04-23
  • 打赏
  • 举报
回复
从写paint
或是 自定义控件
任亚军 2006-04-23
  • 打赏
  • 举报
回复
可能不行吧

110,536

社区成员

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

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

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