Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Setting a transparent label over a progress bar.

Posted on 2004-08-19
3
Medium Priority
?
1,767 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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