我制作了一个无边框表格,并将我的背景图片(PNG 格式)设置为如下图所示。我想要的是使表单的背景透明,以便只显示圆形图像。我尝试将表单更改为BackColor
,Transparent
但出现错误提示Property value is not vald
问问题
40515 次
6 回答
9
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TransparencyKey = Color.LightBlue
Me.BackColor = Color.LightBlue
End Sub
于 2015-02-19T20:41:41.093 回答
3
如果背景颜色为透明工作,您可以将TransparencyKey
属性设置为您的表单以使白色透明。
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TransparencyKey = Color.White 'if this doesn't work you try:
'Me.TransparencyKey = Me.BackColor
End Sub
于 2014-02-15T14:47:57.223 回答
1
尝试这个
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = Color.Transparent
End Sub
(或者)
在构造函数中调用表单的 SetStyle 方法。
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
于 2014-02-15T15:04:20.503 回答
1
Public Class Form1
Private _InitialStyle As Integer
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure MARGINS
Public LeftWidth As Integer
Public RightWidth As Integer
Public TopHeight As Integer
Public Buttomheight As Integer
End Structure
<Runtime.InteropServices.DllImport("dwmapi.dll")>
Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As MARGINS) As Integer
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSet1.MainMenuMaster' table. 'You can move, or remove it, as needed.
Try
Me.BackColor = Color.DarkBlue
Dim margins As MARGINS = New MARGINS
margins.LeftWidth = -1
margins.RightWidth = -1
margins.TopHeight = -1
margins.Buttomheight = -1
Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, margins)
Catch ex As Exception
Application.Exit()
End Try
End Sub
End Class
于 2015-02-19T20:47:06.293 回答
0
Label1.BackgroundColor = color.FromArgb(25, color.blue)
于 2015-06-17T11:18:58.947 回答
0
您可以尝试从设计方面设置表单的属性
返回颜色=系统>活动标题并设置透明度>活动标题
并将以下代码写入表单构造函数或激活事件:
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.BackColor = Color.Transparent
于 2016-10-09T05:34:09.837 回答