PictureBox
is not suitable here. You need to render the image directly on your custom control or some suitable available control, like
Panel
. To do so, you need to handle the event
Paint
, or, in your derived class, override the virtual method
OnPaint
. For drawing, use the instance of
System.Drawing.Graphics
reference passed in even arguments parameter. Of course, transparency makes sense if 1) your image itself supports transparency and have semi-transparent pixels (with opacity less then 1) and 2) your background is not uniform so you have something to see through.
After all, transparency should be considered as a sort of metaphor. On screen, each resulting pixel is shown and is 100% opaque. Opacity (alpha value) of a pixel in pixel types supporting alpha channel is used to get final combined pixel value.
Please see my past answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^],
capture the drawing on a panel[
^],
Drawing Lines between mdi child forms[
^].
Also, perhaps it's worth noting that
PictureBox
is heavily abused by many. This control is not image or a picture, this is a totally redundant control rendering an image, which can be easily implemented on the application level. It's only value is the shortcut in code, just using this available control type for the simplest chores, showing a static image without any effects. An attempt to do anything a bit more complicated is a total waste. Please see my past answers:
Append a picture within picturebox[
^],
How do I clear a panel from old drawing[
^],
draw a rectangle in C#[
^].
—SA