| | |
Setting transparency color in a groupBox
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 38
Reputation:
Solved Threads: 0
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:
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:
C# Syntax (Toggle Plain Text)
public Form1() { InitializeComponent(); this.Closing += new CancelEventHandler(Form1_Closing); //I thought this had to be enabled - but didn't work //this.SetStyle(ControlStyles.UserPaint, true); //ControlStyles.UserPaint = true; //According to MSDN, this is how it's supposed to be done - but it won't work. this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; this.groupBox1.BackColor = Color.Transparent; }
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
Transparent Key = ?
Example
If you select Red as GroupBox background
Transparent Key = Red
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Aug 2008
Posts: 38
Reputation:
Solved Threads: 0
•
•
•
•
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
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.
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Aug 2008
Posts: 38
Reputation:
Solved Threads: 0
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.
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Aug 2008
Posts: 38
Reputation:
Solved Threads: 0
•
•
•
•
Can you send me your code to examine it myself if there's no problem.
But, does it matter whether the Form is a MDI container, or not?
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.
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
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Aug 2008
Posts: 38
Reputation:
Solved Threads: 0
•
•
•
•
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.
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.
![]() |
Other Threads in the C# Forum
- Previous Thread: Initiating form on button click
- Next Thread: Splitter lock question
| Thread Tools | Search this Thread |
.net access algorithm angle array asp.net barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ image index input install java label leak libraries list listbox loop mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml






