vb.net Picture box with a .png with a transparent background loaded in it?

43,240

Just set the background picture to be the parent of the foreground picturebox and the transparancy will work without need for any additional coding

     With PictureBox1

        .Image = My.Resources._00_lichaam
        .SizeMode = PictureBoxSizeMode.Zoom
    End With
    With PictureBox2
        .Parent = PictureBox1
        .Image = My.Resources._01_Hoofd
        .SizeMode = PictureBoxSizeMode.Zoom
        .BackColor = Color.Transparent
    End With

That should work

Share:
43,240
Andy
Author by

Andy

Updated on June 19, 2020

Comments

  • Andy
    Andy almost 4 years

    Ive got a .png file called donkey1.png - it has a transparent background and I have loaded it into a picturebox called pcbDonkey1 - I have changed the properties of the picturebox to have the backcolor transparent - This does not work as it still crosses over another image and has a white background.

    I've heard about using GDI to draw this image so it will have a transparent image and be able to cross the over image without the white background.

    How would you do this?

    Thanks

  • Laxmikant Bhumkar
    Laxmikant Bhumkar over 6 years
    Just used this with already drawn two picture box and done..! PictureBox2.Parent = PictureBox1