Text over progressbar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rene Sørensen

    Text over progressbar

    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

  • John Davison

    #2
    Re: Text over progressbar

    Rene Sørensen wrote:[color=blue]
    > 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
    >[/color]

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

    John

    Comment

    • Rene Sørensen

      #3
      Re: Text over progressbar

      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.W indows.Forms.Pa intEventArgse)
      {
      Graphics G = e.Graphics;
      G.DrawString( "Hello Mum!", new Font( "Verdana", 20 ),
      new SolidBrush( Color.Tomato ),
      650,
      360 );

      }

      On Fri, 22 Apr 2005 22:05:54 -0400, John Davison
      <nospamplease@y ahoo.com> wrote:
      [color=blue]
      >Rene Sørensen wrote:[color=green]
      >> 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
      >>[/color]
      >
      >override the OnPaint method, call the base, then do your own painting
      >
      >John[/color]


      Comment

      • John Davison

        #4
        Re: Text over progressbar

        Rene Sørensen wrote:[color=blue]
        > 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.W indows.Forms.Pa intEventArgse)
        > {
        > Graphics G = e.Graphics;
        > G.DrawString( "Hello Mum!", new Font( "Verdana", 20 ),
        > new SolidBrush( Color.Tomato ),
        > 650,
        > 360 );
        >
        > }[/color]

        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

        Comment

        Working...