O
Orion-Dev
Guest
Hello, I have been struggling for the past few hours trying to make an opaque panel. This is a visual basic windows form program and I am using Visual Studio 2019 Preview.
In the simple example program below, there is a panel with two labels and a button. There is also a second panel that is set to visible = false. When the button is clicked, this second panel is supposed to become visible and cover most of the first panel.
The problem I am having is that panel #2 is supposed to be opaque. It is supposed to cover most of panel #1 and the two labels yet its opacity allowing the labels to show through to some degree.
No matter what I have tried, panel #2 always remains solid, without the slightest degree of opacity.
I tried replacing panel #2 with a form and setting the form's opacity to .01. That didn't work. I tried creating a bitmap and painting a rectangle on it with a brush using a low alpha value, then setting that bitmap to the panel's background. That also did not work.
Can someone please help me understand what I am doing wrong? I have found a number of old visual basic forum discussions where my desired effect was being achieved just by setting a panel's background color to something such as this:
panel2.BackColor = Color.FromArgb(50, Color.Blue) but that did not work for me.
I attached 2 screenshots of what is happening, before and after the button is clicked. I also included a google image that shows the effect I am trying to achieve.
Here is the program:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Panel2.Visible = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Panel1.Controls.Add(Panel2)
Panel2.BackColor = Color.FromArgb(50, 30, 144, 255)
Panel2.Location = New Point(0, Label1.Location.Y)
Panel2.Width = Panel1.Width
Panel2.Height = Panel1.Height - Panel2.Location.Y
Panel2.BringToFront()
Panel2.Visible = True
End Sub
End Class
Continue reading...
In the simple example program below, there is a panel with two labels and a button. There is also a second panel that is set to visible = false. When the button is clicked, this second panel is supposed to become visible and cover most of the first panel.
The problem I am having is that panel #2 is supposed to be opaque. It is supposed to cover most of panel #1 and the two labels yet its opacity allowing the labels to show through to some degree.
No matter what I have tried, panel #2 always remains solid, without the slightest degree of opacity.
I tried replacing panel #2 with a form and setting the form's opacity to .01. That didn't work. I tried creating a bitmap and painting a rectangle on it with a brush using a low alpha value, then setting that bitmap to the panel's background. That also did not work.
Can someone please help me understand what I am doing wrong? I have found a number of old visual basic forum discussions where my desired effect was being achieved just by setting a panel's background color to something such as this:
panel2.BackColor = Color.FromArgb(50, Color.Blue) but that did not work for me.
I attached 2 screenshots of what is happening, before and after the button is clicked. I also included a google image that shows the effect I am trying to achieve.
Here is the program:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Panel2.Visible = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Panel1.Controls.Add(Panel2)
Panel2.BackColor = Color.FromArgb(50, 30, 144, 255)
Panel2.Location = New Point(0, Label1.Location.Y)
Panel2.Width = Panel1.Width
Panel2.Height = Panel1.Height - Panel2.Location.Y
Panel2.BringToFront()
Panel2.Visible = True
End Sub
End Class
Continue reading...