I have 2 PictureBox elements in my WinForms app. I want the gray PictureBox to display an image, and the one above it will be used as some kind of a canvas for drawing a rectangle. But I can't get the PictureBox to be transparent, all the time, when I launch the app it displays the color, white (or the one you see the picture box in), I have set the BackColor of that PictureBox to Transparent, but it still doesn't work.
Asked
Active
Viewed 761 times
0

AGlasencnik
- 139
- 1
- 12
-
See [if this](https://stackoverflow.com/a/15523544/5734097) works for you. It is for Panel, but I think may work with PictureBox too. – D.Kastier Mar 04 '22 at 18:50
-
@D.Kastier Thank you for your answer, but sadly it did nothing. – AGlasencnik Mar 04 '22 at 18:57
-
I can't see images, do the picture boxes touch at all? Also are you sure that you're not seeing what's behind the picture box? – Trevor Mar 04 '22 at 19:02
-
[Translucent circular Control with text](https://stackoverflow.com/a/51435842/7444103) – Jimi Mar 04 '22 at 19:04
-
@Trevor In my form I have a PictureBox that is displaying an image. That picture box is under another picturebox, which is used like a canvas for drawing rectangles. But I want the canvas PictureBox to be Transparent, so I could see the image below and use the canvas at the same time. – AGlasencnik Mar 04 '22 at 19:10
-
Overlay Transparent Panel: [WebBrowser Control disable mouse clicks](https://stackoverflow.com/a/51434828/7444103) (supports transparent colors) -- [Transparent image over two controls with different back colors](https://stackoverflow.com/a/54261539/7444103) (VB.Net) – Jimi Mar 04 '22 at 19:10
-
@Jimi I tried the second answer but that did nothing sadly. – AGlasencnik Mar 04 '22 at 19:16
-
That's a completely transparent Panel. You see nothing unless you draw something inside it (draw, not assign, an Image). Or draw the background using semi-transparent Colors. This other one uses a semi-transparent animation: [Transparent Overlapping Circular Progress Bars (Custom Control)](https://stackoverflow.com/a/53379442/7444103). – Jimi Mar 04 '22 at 19:18
-
@Jimi I just can't seem to get it to work, also I am a beginner, so I don't know what I'm doing, I'll probably just use form as a picturebox as I found out that would work, but it lags a lot. Thanks a lot for the answer anyway. – AGlasencnik Mar 04 '22 at 19:22
1 Answers
1
It is quite easy all you have to do is make the canvas PictureBox of the same size and set its location also the same as your first picture box. Then set canvas PictureBox back colour to transparent. Now set your first PictureBox as the parent of canvas PictureBox.
You can write the below code on the form load event.
pictureBoxCanvas.Size = pictureBox1.Size;
pictureBoxCanvas.Location = pictureBox1.Location;
pictureBoxCanvas.BackColor = Color.Transparent;
pictureBoxCanvas.BringToFront();
pictureBoxCanvas.Parent = this.pictureBox1;

Nikunj Gaur
- 94
- 8