Solved

Setting a transparent label over a progress bar.

Posted on 2004-08-19
3
1,615 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now