2

我正在使用 Visual Basic 中的第一个应用程序,我正在使用 Visual Basic Studio...我创建了一个带有按钮的表单 - 表单有一个带圆角的背景图像,我无法将其颜色设置为“透明”,因为发生以下错误:

Control does not support transparent background colors.

现在我不知道该怎么办。我已经读到我可以通过添加以下行来设置代码的透明度:

SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.BackColor = Color.Transparent

但它似乎不起作用......那我还能做什么?

整个代码:

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
4

2 回答 2

4

对于表格,试试这个:

Me.TransparencyKey = Me.BackColor

由于您有背景图像,因此请确保选择图像中未找到的背景颜色。

于 2012-11-21T00:08:56.187 回答
0

只需更改表单的 Opacity 属性。

于 2012-11-21T05:23:15.053 回答