Text over progressbar

  • Thread starter Thread starter Rene Sørensen
  • Start date Start date
R

Rene Sørensen

Hi

Is there a way to show text in/over a progressbar (like using a label
with transparent background? Which hasn't worked for me, BTW)???

Rene
 
Rene said:
Hi

Is there a way to show text in/over a progressbar (like using a label
with transparent background? Which hasn't worked for me, BTW)???

Rene

override the OnPaint method, call the base, then do your own painting

John
 
Hi john

I did the OnPaint, (se beneath), just a small test,
but the
< call the base, then do your own painting >
you suggest, I don't exactly know what you mean about this.

This code works, but not the way I hoped, the string is drawn behind
my Progress bar control, so is there another way I can do this, or is
Graphics the wrong one to use?

private void OnPaint(object
sender,System.Windows.Forms.PaintEventArgse)
{
Graphics G = e.Graphics;
G.DrawString( "Hello Mum!", new Font( "Verdana", 20 ),
new SolidBrush( Color.Tomato ),
650,
360 );

}
 
Rene said:
Hi john

I did the OnPaint, (se beneath), just a small test,
but the
< call the base, then do your own painting >
you suggest, I don't exactly know what you mean about this.

This code works, but not the way I hoped, the string is drawn behind
my Progress bar control, so is there another way I can do this, or is
Graphics the wrong one to use?

private void OnPaint(object
sender,System.Windows.Forms.PaintEventArgse)
{
Graphics G = e.Graphics;
G.DrawString( "Hello Mum!", new Font( "Verdana", 20 ),
new SolidBrush( Color.Tomato ),
650,
360 );

}

I'm sorry, I forgot ProgressBar is a sealed class. After quickly
studying the class, I could not find a way to do what you want to do.
You *could* obtain the Graphics object for the progress bar, and draw on
top of that, but you would not know when the control repaints itself,
because ProgressBar does not have a Paint event.

I think your best bet would be to create your own ProgressBar control
using the drawing primitives. I don't think that would be very difficult.

John Davison
Compass Engineering Group
 
Back
Top