Make Picturebox transparent over other picturebox?

2020-08-01 06:27发布

问题:

I have two Picturebox and both should be transparent background, but the real problem is both transparent for form background but not over each other .

here's photo of my problem: http://www.saj-sa.com/problem.gif

回答1:

Picturebox1.visible = true  \\ will turn on a box
Picture box.visible = false \\ will turn a box off

Place both boxes over one another then turn on the one you want to be seen, and off the one you do not want to see, reverse the order to switch between them.



回答2:

Me.Picturebox2.Parent = Me.Picturebox1 : Me.Picturebox2.Visible = True


回答3:

add panel 1 and set image to panel 1 add panel 2 and set image to panel 2

drag panel 1 or 2 into panel 1 or 2 you want to make it behind or front

so it transparent



回答4:

I think op want to have both image visible, but the 1st girl transparent part to be really transparent, and not hide the other girl.

to achieve that you need add all of your image into the SAME graphic element, starting from the deepest one ( background) to the highest one ( the one on the top )

 private back as New bitmap("C:/background.bmp") 
 private girlOnTop as New bitmap("C:/topGirl.bmp") 
 private girlInMiddle as New bitmap("C:/middleGirl.bmp") 

'set the size of your graphic base on the background 

 Dim BMP As New Bitmap(back.Width, back.Height) 

'create a graphic base on that
 Dim GR As Graphics = Graphics.FromImage(BMP)

'draw onto your bmp starting from the background
 GR.DrawImage(back, 0, 0)

'set X,y to the coordinate you want your girl to appear
 GR.DrawImage(middleGirl, X, Y)
 GR.DrawImage(topGirl, X, Y)

'clear the picturebox
pbox1.Image = Nothing

'now that we have draw all our image onto the same bitmap, assign it to your picturebox element
pbox1.Image = BMP