Click here to Skip to main content
15,035,723 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Guys,

I am trying to make a menu using panels and buttons in a C# Winforms project.
Previously i Set the background to transparent and it was working, now i am trying to set it to transparent in the properties with no luck, Need Help

this.OrganizationMenuPanel.BackColor = System.Drawing.Color.Transparent;
            this.OrganizationMenuPanel.Location = new System.Drawing.Point(148, 148);
            this.OrganizationMenuPanel.Name = "OrganizationMenuPanel";
            this.OrganizationMenuPanel.Size = new System.Drawing.Size(171, 372);
            this.OrganizationMenuPanel.TabIndex = 4;
            this.OrganizationMenuPanel.Visible = false;
            this.OrganizationMenuPanel.Leave += new System.EventHandler(this.OrganizationMenuPanel_Leave);
            this.OrganizationMenuPanel.MouseEnter += new System.EventHandler(this.OrganizationMenuPanel_MouseEnter);
            this.OrganizationMenuPanel.MouseLeave += new System.EventHandler(this.OrganizationMenuPanel_MouseLeave);
            this.OrganizationMenuPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OrganizationMenuPanel_MouseMove);

What I have tried:

it was working and now its not anymore i don't know what to try
Updated 18-Mar-20 5:11am
Mehdi Gholam 1-Oct-17 10:57am
What changed in your environment?
ezanaw 1-Oct-17 12:17pm
nothing as far as i can tell

In Windows Forms, Transparent isn't. All that does is tell the control to take on the fore/back ground properties of the container that contains it.

For example, you put a Panel on a Form. If you set the BackColor of the Panel to Transparent, the Panel will take on the BackColor property of the Form. It does NOT make the Panel see-through.

There are some articles and forum answers out there that take you through making your own pseudo-transparent Panel control by not drawing the background of the Panel. This technique may or may not do the trick for you, depending on what's going on on your Form behind your Panel control.

c# - Any trick to use opacity on a panel in Visual Studio Window Form? - Stack Overflow[^]
Make panel transparent[^]
try by setting form background and transparencykey same
this.BackColor = Color.Red;
this.TransparencyKey = Color.Red;
this.FormBorderStyle = FormBorderStyle.None;
Dave Kreskowiak 11-Oct-19 22:20pm
You didn't read my answer from 2 years ago, did you?

You also didn't read the documentation on TransparencyKey either. It applies to Forms, not to Controls, like Panel.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900