?
Solved

Setting a transparent label over a progress bar.

Posted on 2004-08-19
3
Medium Priority
?
1,723 Views
Last Modified: 2012-06-14
How do i set a transparent label over a progressbar in C#?

I'm placing a label over a progressbar and i want just the label's text only to be seen.
How do i do this?

Thanks
0
Comment
Question by:3Mann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
AdrianJMartin earned 800 total points
ID: 11850800
For some reason you cannot inherit from ProgressBar and implement this.

But you can add a handler for ProgressBar.Invalidated event and use some code like:-

      StringFormat sf = StringFormat.GenericDefault ;
      sf.Alignment = StringAlignment.Center ;
      sf.LineAlignment = StringAlignment.Center ;

      Graphics g = progressBar1.CreateGraphics();
      g.DrawString( "Transparancy" , Font , SystemBrushes.WindowText , progressBar1.Width / 2  , progressBar1.Height / 2  , sf );
      g.Dispose();
0
 
LVL 1

Author Comment

by:3Mann
ID: 12013741
ey adrian :D
nice one :D

i cudnt make it work in the invalidated event though. so i just placed a similar code everytime i update the progbar.
0
 

Expert Comment

by:vigorniensis
ID: 38083014
I couldn't make it work either so I too placed it whenever I changed the Progress Bar. Sadly though this simply didn't work or look anything like working.

        Dim sf As StringFormat  = StringFormat.GenericDefault
       
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center

        Dim g As Graphics = pbStorageUsed.CreateGraphics()
        g.DrawString( labFreeSpace.Text , Font , SystemBrushes.WindowText , CInt(pbStorageUsed.Width / 2)  , CInt(pbStorageUsed.Height / 2)  , sf )
        g.Dispose()

Does the author have an explanation for absolutely nothing appearing?  (Yes, there is text in labFreeSpace.Text).

Vig.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question