Winform setting Panel container background is PictureBox

Source: Internet
Author: User

1. To realize the transparency of controls and backgrounds in C # WinForm, you can set their parent control by setting the control's BackColor property to Transparent. Because in C #, the transparency of the control refers to the transparency of the parent form. If you do not set the Parent property, the control will only be transparent to the form and will be displayed with the background color of the form (the default control) re-brushed again as its own background.
2. With more controls, you can use the Panel control to place a group of controls in a panel, and then set the background transparency only for this panel, and the other controls follow the background transparency.
Demo

With an existing PictureBox control, more than 10 labels, and a button, only these labels and buttons are placed in the panel. Also, add the following code to the Form_Load event to make the background transparent:
This.picturebox1.SendToBack ();//Place the background image at the bottom
This.panel1.BackColor = color.transparent;//Panel is set to transparent
This.panel1.Parent = this.picturebox1;//Sets the panel parent control as a background picture control
This.panel1.BringToFront ();//Put panel in front
The above code enables all controls to be transparent to the pictuebox background image.

Winform setting Panel container background is PictureBox

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.