Implementation of label background transparency in WinFrom

  • 2020-11-03 22:33:41
  • OfStack

This article illustrates the implementation method of label background transparency in WinFrom, which has a good practical value in application development. Share to everybody for everybody reference. Specific implementation methods are as follows:

Use:


lblPstart.BackColor=Color.Transparent;

You can make the lable control's background color transparent. You can see the background color for the lable container, but this background color must be the background color for the form.

Such as:


From1.Controls.Add(lable1);  
lable1.BackColor=Color.Transparent; 

Thus, lable1 is transparent
But if it is:


From1.Contorls.Add(pictureBox1);// Or some other container control   
pictureBox1.Controls.Add(lable1);  
lable1.BackColor=Color.Transparent;

The result is lable1, which is still transparent, but the color you see is the background color of its container control, which is pictureBox1, not the background color of forms Form1.
The above code can be found in


#region  Windows   Code generated by the forms designer   
///  <summary>  
///   The designer supports the required methods   -   Do not modify using the code editor   
///   The contents of this method.   
///  </summary>  
private  void  InitializeComponent()

View in method


this.pictureBox1.Controls.Add(this.label1); 

This sets label transparently to the background color of picturebox

Hopefully this article has helped you with your C# programming


Related articles: