PictureBox在vb.net中的所有工具中都是透明的

时间:2016-09-01 08:05:58

标签: .net vb.net picturebox

如何让PictureBox透明化。

我的工作:

My work

我已经将PictureBox BackColour设置为透明,但我仍然看不到DataGridView也是状态标签旁边的TextBox。

有人可以帮我实现这样的目标。

我想要实现:

I want to acheive

提前致谢:)

1 个答案:

答案 0 :(得分:1)

将背景颜色设置为Transparent可能会导致误解。您看到的白色是表单背景。

如果没有在表格Paint事件

中自行绘制图片,则无法使控件透明化

修改

假设你有一个DataGridView1控件想要绘制图像:

Private Sub DataGridView1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles DataGridView1.Paint

        ' Create image.
        Dim newImage As Image = Image.FromFile("pic.png")

        ' Adjust this as you need
        Dim x As Single = 100
        Dim y As Single = 50
        Dim width As Single = 100
        Dim height As Single = 100

        ' Draw image on top of the control
        e.Graphics.DrawImage(newImage, x, y, width, height)

    End Sub