问题
When i run my code, the picture box has a background colour, even though I have set the background colour to transparent in the properties window. any ideas?
回答1:
I assume you're overlapping a PictureBox
over some other control and expecting to see through the PictureBox
. That's not how it works - controls with transparent backgrounds are only transparent relative to their parent, not other controls. You could draw them using GDI+ by overriding the OnPaint
method of your form:
Private Shared ReadOnly SomeImage As Image = My.Resources.blah 'Get your image somewhere
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
g.DrawImage(SomeImage, xCoordinate, yCoordinate)
'Draw as many images or text as you want.
End Sub
Also, it seems that people are mostly looking for this functionality to make a game. Are you making a game? Please learn graphics before making a game if this is the case. There are many good tutorials out there.
来源:https://stackoverflow.com/questions/9342274/picture-box-transparency-in-vb