(Oct 29, 2014 01:12 PM)WZDY Wrote: He could just do it in the Properties of the textbox?
😊 what textbox
want short code
Code
class TextProgressBar : ProgressBar
{
public TextProgressBar()
{
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics G = e.Graphics;
ProgressBarRenderer.DrawHorizontalBar(G, ClientRectangle);
if (Value > 0) {
ProgressBarRenderer.DrawHorizontalChunks(G, new Rectangle(ClientRectangle.X, ClientRectangle.Y, Convert.ToInt32(Math.Round((Convert.ToSingle(Value) / Maximum) * ClientRectangle.Width)), ClientRectangle.Height));
}
SizeF TextSize = G.MeasureString(Value, new Font("Segoe UI", 10));
G.DrawString(Value, new Font("Segoe UI", 10), Brushes.Black, new Point((Width / 2) - (TextSize.Width / 2), (Height / 2) - (TextSize.Height / 2)));
}
}