0

My problem is like that: I have a Windows Form Application and it contains a picture which is in a picturebox. The picture contains mostly transparent parts and picture box is also transparent. So when I change backgroundcolor property of form, picture background changes also. But I want to put many labels behind picturebox, and when I change backgroundcolor of any label, it should be seen behind the picturebox and only as color of transparent part.

If I make parent of picturebox as label, this works but it tries to place picture box into label, so if label is small, the picture is not seen.

Sorry for my grammar mistakes, thanks for your help.

Baacus
  • 21
  • 1
  • 7
  • Is the problem only *"it tries to place picture box into label"*? You don't have to every time use winforms designer to create layouts. – Sinatr Sep 27 '17 at 13:02
  • You need to post what you've tried so far. – dcg Sep 27 '17 at 13:02
  • You shouldn't use Windows Forms for Desktop development "anymore", you should go with WPF, with WPF you can do whatever you want to even have overlapping components – rmjoia Sep 27 '17 at 13:06
  • you should be able to overlap components by the sounds of it you have set the parent of the picture box to be the label – BugFinder Sep 27 '17 at 13:07
  • This is not possible. You can only see the the Background of the PBox's Parent. So you would have to nest the PBox in the Label.. Transparency os __not supported__ for overlapping controls, only for nested ones! – TaW Sep 27 '17 at 13:22
  • Hi, thanks for your answers. I want to clarify the problem so I uploaded some pics. [Pic1] (https://1drv.ms/i/s!Am4a4VifmJlThYQvZoAE_OBQHARrAw) This is my pic and I want to put many labels like label1 and label2, I want these labels not to cover lines of the pic and to be seen only as bckgrndclr. If I enlarge label1 and make parent of pb as label1, label1 can be as bckgrndclr of pb [Pic2] (https://1drv.ms/i/s!Am4a4VifmJlThYQttWOQqgb-U3SsTg) .But if label1 is smaller than pic and parent of pb again, pb is lost and can not be seen [Pic3] (https://1drv.ms/i/s!Am4a4VifmJlThYQuzK6u6QsczKmRhw) . – Baacus Sep 28 '17 at 17:59
  • Well you could draw the label text into a Bitmap, which then set as the BackgroundImage of the PBox. Or you draw everthing in the Paint event, labels, image, all. Then your order will decide what covers what.. – TaW Sep 28 '17 at 22:51

1 Answers1

0

You can add a label behind a picture box. Set BackColor of PictureBox to Transparent.

Right-Click on the PictureBox and click on "Send to Back" Right-Click on the label and click on "Bring to Front"

or at Form_Load event do

PictureBox.SendToBack();
Hannan Ayub
  • 378
  • 2
  • 15