Setting transparency color in a groupBox

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2008
Posts: 38
Reputation: Ajantis is an unknown quantity at this point 
Solved Threads: 0
Ajantis Ajantis is offline Offline
Light Poster

Setting transparency color in a groupBox

 
0
  #1
Jan 6th, 2009
Hello there,

I have some troubles making transparency of my menues in C#. Basically, I can't make them work. :/ I've searched Google, MSDN, codeproject, c-shaprcorner... but I still can't make it work.

I try to set a groupBox BackColor to transparent, and let the groupBox use my own background image (.PNG format).
Can anyone help please?

Here's a bit how I did:

  1. public Form1()
  2. {
  3. InitializeComponent();
  4. this.Closing += new CancelEventHandler(Form1_Closing);
  5. //I thought this had to be enabled - but didn't work
  6. //this.SetStyle(ControlStyles.UserPaint, true);
  7. //ControlStyles.UserPaint = true;
  8.  
  9. //According to MSDN, this is how it's supposed to be done - but it won't work.
  10. this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  11. this.BackColor = Color.Transparent;
  12. this.groupBox1.BackColor = Color.Transparent;
  13.  
  14.  
  15. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Setting transparency color in a groupBox

 
0
  #2
Jan 6th, 2009
Just select a background color for th GroupBox, then in form properties say that color you selected is Transparent from Form properties
Transparent Key = ?
Example
If you select Red as GroupBox background
Transparent Key = Red
Attached Thumbnails
Transparncy.jpg  
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Setting transparency color in a groupBox

 
0
  #3
Jan 6th, 2009
Without writing single line of code!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 38
Reputation: Ajantis is an unknown quantity at this point 
Solved Threads: 0
Ajantis Ajantis is offline Offline
Light Poster

Re: Setting transparency color in a groupBox

 
0
  #4
Jan 6th, 2009
Originally Posted by RamyMahrous View Post
Just select a background color for th GroupBox, then in form properties say that color you selected is Transparent from Form properties
Transparent Key = ?
Example
If you select Red as GroupBox background
Transparent Key = Red
Just tried. Didn't work.
I tried setting the transparency color to "Maroon", and added that Transparency Key in my Form1.
This was the outcome. I can't see the whole document behind the menu.
Attached Thumbnails
Namnlös.jpg  
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Setting transparency color in a groupBox

 
0
  #5
Jan 6th, 2009
I don't know but, did you try to send the menu to back or bring the new document to front?
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 38
Reputation: Ajantis is an unknown quantity at this point 
Solved Threads: 0
Ajantis Ajantis is offline Offline
Light Poster

Re: Setting transparency color in a groupBox

 
0
  #6
Jan 6th, 2009
Originally Posted by RamyMahrous View Post
I don't know but, did you try to send the menu to back or bring the new document to front?
I don't know what you mean, but - the new document should be placed behind - so that's no problem. But - the maroon color should be transparent in the groupBox, so that the document could show.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Setting transparency color in a groupBox

 
0
  #7
Jan 6th, 2009
Can you send me your code to examine it myself if there's no problem.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 38
Reputation: Ajantis is an unknown quantity at this point 
Solved Threads: 0
Ajantis Ajantis is offline Offline
Light Poster

Re: Setting transparency color in a groupBox

 
0
  #8
Jan 6th, 2009
Originally Posted by RamyMahrous View Post
Can you send me your code to examine it myself if there's no problem.
I'm sorry, I can't give out my code. :/ I've been working on it for a very long time. This is all I need to do. Just setting the transparency of the groupBox.

But, does it matter whether the Form is a MDI container, or not?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,908
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 273
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: Setting transparency color in a groupBox

 
0
  #9
Jan 6th, 2009
Why don't you use something like Mygroupbox.BackColor = Color.FromArgb(alpha,Color.Maroon);
alpha being the transparancy : 0 = completly transparant , 255 = completly opaque.
Have not tested it, hope it helps.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 38
Reputation: Ajantis is an unknown quantity at this point 
Solved Threads: 0
Ajantis Ajantis is offline Offline
Light Poster

Re: Setting transparency color in a groupBox

 
0
  #10
Jan 6th, 2009
Originally Posted by ddanbe View Post
Why don't you use something like Mygroupbox.BackColor = Color.FromArgb(alpha,Color.Maroon);
alpha being the transparancy : 0 = completly transparant , 255 = completly opaque.
Have not tested it, hope it helps.
Just tried it. Won't work. I mean - the code works, but there is no transparency. Only that dull gray "Control Gray" color... which lets nothing through....

It's got the same color as my MDI Container (my form is one). And it just REFUSES to go away in my groupBox.
The effect are the same as in the picture I post earlier, but without the maroon color.
Last edited by Ajantis; Jan 6th, 2009 at 2:58 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC