110,561
社区成员
发帖
与我相关
我的任务
分享
//frmLogin_Load 在窗体载入的时候写一下代码 应该可以实现的 我就这样做的
this.label1.BackColor = Color.Transparent;
this.pictureBox1.Controls.Add(this.label1);
class PercentageProgressBar : ProgressBar
{
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
const int WM_PAINT = 15;
if (m.Msg == WM_PAINT && this.Value > 0 && this.Maximum > 0)
{
using (Graphics g = this.CreateGraphics())
{
string percentage = string.Format("{0:P2}", (float)this.Value / this.Maximum);
StringFormat sf = new StringFormat();
sf.Alignment = sf.LineAlignment = StringAlignment.Center;
g.DrawString(percentage, SystemFonts.DefaultFont, Brushes.Black, this.ClientRectangle, sf);
}
}
}
}
Label1.BackColor=Color.Transparent
Label1.Parent = this.pictureBox1;