Solved

Setting a transparent label over a progress bar.

Posted on 2004-08-19
3
1,654 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

789 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