1. Custom Transparent Background Panel control : Add Class TransparentPanel.cs in Project
Using system.windows.forms;using system.drawing;
public class Transparentpanel:control {public Transparentpanel () {} Pro tected override void OnPaintBackground (PaintEventArgs e) {//Draw without background} protected override CreateParams CreateParams {get {createparams CP = base. CreateParams; Cp. ExStyle |= 0x00000020; //ws_ex_transparent return CP; }} protected override void OnPaint (System.Windows.Forms.PaintEventArgs e) {//Draw panel background map Like if (backgroundimage!= null) e.graphics.drawimage (this. BackgroundImage, New Point (0, 0)); ////Add a custom property value for the control num1//private int num1 = 1; [Bindable (True), Category ("Custom property Bar"), DefaultValue (1), Description ("Here is the description of the custom attribute ATTR1! ")]//public int Attr1//{//get {return NUM1;} set {this. Invalidate (); } //} }
2, F5 compile run once, you can find the control in the toolbarTransparentpanel.
After you add the control to the forms form, set its Image property to see the transparency in the *.png image with transparency information.
C # Transparent Background panel, transparent image, piturebox transparency effect