I am trying to get my form in order to have transparent background in vb.net
Currently, in the New form, I installed
Me.SetStyle(ControlStyles.SupportsTransparentBackColor, true)
But the shape looks like it has a gray color by default
Can anyone help?
EDIT: I need the form controls to be visible, so I don't think setting opacity to 0 will work
EDIT: I tried the solution for the transparent key, but it does not work. I have a circular image with a black background. OnPaint I set the transparency key in the img pixel to 0,0, this leaves me with a circular image (which I want). It hides the black background, but I still remain with the gray rectangle by default in the form.
below is the code that I have -
Public Sub New() Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True) Me.BackColor = Color.Transparent ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. Me.Timer1.Start() End Sub Private Sub frmWoll_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim img As Bitmap = CType(Me.BackgroundImage, Bitmap) img.MakeTransparent(img.GetPixel(2, 2)) Me.TransparencyKey = img.GetPixel(2, 2) End Sub
Dean
source share