表格透明度 [英] Form transparency
问题描述
我正在使用visual basic中的第一个应用程序,我正在使用visual basic studio...我创建了一个带有按钮的表单 - 表单有一个带圆角的背景图像,我无法设置其颜色为透明",因为出现以下错误:
I'm in progress with my first application in visual basic, and I'm using the visual basic studio... I have created a form, with buttons - form has an background image with rounded corners and I can not set its color to "transparent" because the following error occurs:
控件不支持透明背景色.
现在我不知道该怎么办.我已经读过我可以通过添加以下几行在代码中设置透明度:
Now I have no idea what to do. I have read that I can set the transparency in the code, by adding the following lines:
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.BackColor = Color.Transparent
但它似乎不起作用......那我还能做什么?
But it doesn't seem to work... So what else can I do?
完整代码:
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
MsgBox("Test", 32, "Button Click")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Close()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.BackColor = Color.Transparent
End Sub
End Class
推荐答案
对于表单,试试这个:
Me.TransparencyKey = Me.BackColor
由于您有背景图片,请确保选择图片中未找到的背景颜色.
Since you have a background image, make sure to pick a BackColor that isn't found in the image.
这篇关于表格透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!