Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How to make a label transparent that sits on a picturebox?
 

How to make a label transparent that sits on a picturebox?

In my application, I have a PictureBox that displays a Bitmap that fills the Form. The heightand width of the PictureBox is set to the bounds of the Bitmap so that I can scroll the form to the parts of the image that are off the display area.

The user is supposed to be able to add text fields on top of the image. I want to use labels for this, because the user is also supposed to be able to change the text and move it around on the image. The problem is that I need to make the labels transparent. That's easy enough to do by setting its Color to Transparent and setting the Form's TransparentKey to Color.Control. But when I do that, it doesn't show the Bitmap in the PictureBox where the label's transparency is. Instead, it shows the Form's background color through it.

I need to be able to have the labels sitting on the PictureBox and have the image in the PictureBox show through the label's transparent areas.I can't figure out how to do this.

Can someone give some advice here?

  • Moved byOmegaManMVPSaturday, June 06, 2009 9:24 PM (From:Visual C# General)
  •  
Brad Younie  Saturday, June 06, 2009 8:46 PM
Hi Brad,

Please set the parent property of the Label to the PictureBox control, and set it's backcolor to transparent. You can refer to this article for sample code.

If that's not what you want, please feel free to let me know.

Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Wednesday, June 10, 2009 4:19 AM
Hi Brad,

Please set the parent property of the Label to the PictureBox control, and set it's backcolor to transparent. You can refer to this article for sample code.

If that's not what you want, please feel free to let me know.

Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Wednesday, June 10, 2009 4:19 AM

You can use google to search for other answers

Custom Search

More Threads

• C# TabOrder Problem in disable button
• creating custom events for combo box
• Auto generating buttons
• Tab and menustrip controls
• How to allow resizing in one direction only?
• Problem with Windows Forms designer when assembly loads another assembly using reflection
• Collection Editor Question
• calender control
• custom designer? plzz help
• Sort DataGrid View on the basis of CheckBox Column