C # Transparent Background panel, transparent image, piturebox transparency effect

Source: Internet
Author: User
Tags transparent image


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

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.