Winforms C#使面板背景透明 [英] Winforms C# make a panel background transparent

查看:93
本文介绍了Winforms C#使面板背景透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在尝试使用C#Winforms项目中的面板和按钮制作菜单。

之前我设置透明的背景,它正在工作,现在我试图在没有运气的情况下将其设置为透明,需要帮助

谢谢



 this.OrganizationMenuPanel.BackColor = System.Drawing.Color.Transparent; 
this.OrganizationMenuPanel.Controls.Add(this.button16);
this.OrganizationMenuPanel.Controls.Add(this.button15);
this.OrganizationMenuPanel.Controls.Add(this.button14);
this.OrganizationMenuPanel.Controls.Add(this.button13);
this.OrganizationMenuPanel.Controls.Add(this.button12);
this.OrganizationMenuPanel.Controls.Add(this.button11);
this.OrganizationMenuPanel.Controls.Add(this.button10);
this.OrganizationMenuPanel.Controls.Add(this.button9);
this.OrganizationMenuPanel.Controls.Add(this.button8);
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);





我尝试了什么:



它正在工作,现在它不再是我不知道该尝试什么

解决方案

在Windows窗体中,透明不是。所有这一切都是告诉控件采用包含它的容器的前/后地面属性。



例如,你将一个面板放在一个表格上。如果将Panel的BackColor设置为Transparent,Panel将采用Form的BackColor属性。它不会使面板透明。



有一些文章和论坛的答案会带你通过不绘制来制作你自己的伪透明面板控件小组的背景。这种技巧可能会或可能不会为你做,这取决于你的Panel控件背后的表格上发生了什么。



c# - 在Visual Studio窗体窗体中使用面板上的不透明度的任何技巧? - Stack Overflow [ ^ ]

使面板透明 [ ^ ]

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
Thanks

this.OrganizationMenuPanel.BackColor = System.Drawing.Color.Transparent;
            this.OrganizationMenuPanel.Controls.Add(this.button16);
            this.OrganizationMenuPanel.Controls.Add(this.button15);
            this.OrganizationMenuPanel.Controls.Add(this.button14);
            this.OrganizationMenuPanel.Controls.Add(this.button13);
            this.OrganizationMenuPanel.Controls.Add(this.button12);
            this.OrganizationMenuPanel.Controls.Add(this.button11);
            this.OrganizationMenuPanel.Controls.Add(this.button10);
            this.OrganizationMenuPanel.Controls.Add(this.button9);
            this.OrganizationMenuPanel.Controls.Add(this.button8);
            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

解决方案

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[^]


这篇关于Winforms C#使面板背景透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆