展开全部
重写这个控件
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
class newlabel : Label
{
protected override void OnPaint(PaintEventArgs e)
{
float lineHeght,lineWidth;
lineHeght = this.Height/2;
lineWidth = this.Width;
base.OnPaint(e);
e.Graphics.DrawLine(Pens.Red, 0, lineHeght, lineWidth, lineHeght);
}
}
你只需要在form初始化时,Label lable1 = new newlabel();
就可以了
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
class newlabel : Label
{
protected override void OnPaint(PaintEventArgs e)
{
float lineHeght,lineWidth;
lineHeght = this.Height/2;
lineWidth = this.Width;
base.OnPaint(e);
e.Graphics.DrawLine(Pens.Red, 0, lineHeght, lineWidth, lineHeght);
}
}
你只需要在form初始化时,Label lable1 = new newlabel();
就可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询