简体   繁体   English

VB.NET透明面板

[英]VB.NET Transparent Panel

I'm trying to use a transparent panel.我正在尝试使用透明面板。 I want add a panel to the center of a form.我想在表单的中心添加一个面板。 This panel should result in darkness.该面板应导致黑暗。

How can I add a transparent panel to my form without a background picture?如何在没有背景图片的情况下将透明面板添加到表单中?

在此处输入图像描述

1)Set the background image of the form to the picture you want as a background and set the background image layout to 'stretch' as shown below. 1)将表单的背景图片设置为您想要的图片作为背景,并将背景图片布局设置为“拉伸”,如下图所示。

在此处输入图像描述

2)Add a panel control. 2)添加面板控件。

3)Size the panel control to cover most of the form. 3) 调整面板控件的大小以覆盖大部分表单。

4)Add the code below to the form load event. 4)将以下代码添加到表单加载事件中。

Panel1.BackColor = Color.FromArgb(185, 0, 0, 0)

5)Set form border style to 'none' 5)将表单边框样式设置为“无”

在此处输入图像描述

6)Add a button to the panel 6)在面板中添加一个按钮

7)Set the buttons Flat Style, Border Size and Forecolor as shown below. 7)设置按钮平面样式,边框大小和前景色,如下图所示。

在此处输入图像描述

8)Add the following code to the form load event. 8)将以下代码添加到表单加载事件中。

Button1.BackColor = Color.FromArgb(75, 240, 240, 240)

9)Compile and there you go 9) 编译,然后 go

在此处输入图像描述

Note:You can use the same method for other controls on the form but remember that it will only be the background image of the form that shows in any control.注意:您可以对表单上的其他控件使用相同的方法,但请记住,它只会是显示在任何控件中的表单的背景图像。 In other words, you can't stack controls on top of each other and see the bottom control because the background of the foremost control will be the background image of the form not the control immediately behind it.换句话说,您不能将控件堆叠在一起并看到底部控件,因为最前面的控件的背景将是窗体的背景图像,而不是紧随其后的控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM