Solved

Setting a transparent label over a progress bar.

Posted on 2004-08-19
3
1,673 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
3 Comments
 
LVL 5

Accepted Solution

by:
AdrianJMartin earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

713 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