Seeking: Panel Opacity & Border
-
Hmm... I think there may have been a misunderstanding. What I'm trying to do is create a panel with opacity, so that when I move it around over other controls, the other controls are visible under it, but the panel's background is still shown, just faded according to its opacity value. Something to the effect of looking at the world through a piece of colored cellophane... If I understand your suggestion correctly, that code will make my panel transparent, but I want it to still be visible, but faded.
-M.
-
Hmm... I think there may have been a misunderstanding. What I'm trying to do is create a panel with opacity, so that when I move it around over other controls, the other controls are visible under it, but the panel's background is still shown, just faded according to its opacity value. Something to the effect of looking at the world through a piece of colored cellophane... If I understand your suggestion correctly, that code will make my panel transparent, but I want it to still be visible, but faded.
-M.
-
I don't understand... why should I create an entire form just to have a customized panel? I'm just looking for a a piece of code to stick in the OnPaint method of a custom panel that'll make it's background have opacity... I've seen it done in VB, but was unable to translate it to C#.
-M.
-
Hello,
adrianna_r wrote:
If I understand your suggestion correctly, that code will make my panel transparent, but I want it to still be visible, but faded.
Only the color of the specified bixel will be transparent. Martin
...But I don't want full transparency on any bit of the panel, just opacity. I want it to look like in this Photoshopped-ed image[^]. (the blue panel isn't fully transparent, but you can still see stuff under it, such as that button)
-M.
-
...But I don't want full transparency on any bit of the panel, just opacity. I want it to look like in this Photoshopped-ed image[^]. (the blue panel isn't fully transparent, but you can still see stuff under it, such as that button)
-M.
-
...But I don't want full transparency on any bit of the panel, just opacity. I want it to look like in this Photoshopped-ed image[^]. (the blue panel isn't fully transparent, but you can still see stuff under it, such as that button)
-M.
Hello, Have you tried changeing the Alpha Level of the BackColor. this.BackColor=Color.FromArgb(128,this.BackColor); All the best, Martin -- modified at 7:43 Wednesday 29th November, 2006 Have it from here. Tried it, but doesn't work????? http://www.eggheadcafe.com/aspnet_answers/NETFrameworkdrawing/Feb2006/post25815823.asp[^]
-
Ok, Only found VB.Net code: http://www.codeproject.com/vb/net/AlphaGradientPanel.asp[^] Martin
I saw that code... but I didn't understand it at all and I don't know how to convert it to C#. There are a lot of abilities in that thing that I don't need, and figuring out which line does what to extract the stuff I want requires VB knowledge that I just don't have. Not to mention the fact that I don't even know if that stuff even -has- a C# counterpart.
-M.
-
Hello, Have you tried changeing the Alpha Level of the BackColor. this.BackColor=Color.FromArgb(128,this.BackColor); All the best, Martin -- modified at 7:43 Wednesday 29th November, 2006 Have it from here. Tried it, but doesn't work????? http://www.eggheadcafe.com/aspnet_answers/NETFrameworkdrawing/Feb2006/post25815823.asp[^]
I have tried that, yeah, without success :-\
-M.
-
I don't understand... why should I create an entire form just to have a customized panel? I'm just looking for a a piece of code to stick in the OnPaint method of a custom panel that'll make it's background have opacity... I've seen it done in VB, but was unable to translate it to C#.
-M.
Something like this?
public partial class CustomPanel : Panel { Color color; public CustomPanel() { InitializeComponent(); color = Color.FromArgb(100, Color.Blue); } protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT return cp; } } protected override void OnPaintBackground(PaintEventArgs e){} protected override void OnPaint(PaintEventArgs e) { using (Brush brush = new SolidBrush(color)) { e.Graphics.Clear(Color.Transparent); e.Graphics.FillRectangle(brush, this.ClientRectangle); } } }
-
Something like this?
public partial class CustomPanel : Panel { Color color; public CustomPanel() { InitializeComponent(); color = Color.FromArgb(100, Color.Blue); } protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT return cp; } } protected override void OnPaintBackground(PaintEventArgs e){} protected override void OnPaint(PaintEventArgs e) { using (Brush brush = new SolidBrush(color)) { e.Graphics.Clear(Color.Transparent); e.Graphics.FillRectangle(brush, this.ClientRectangle); } } }
Yes! I've no idea why it works, but it does. Many thanks!
-M.