博客
关于我
c#透明panel
阅读量:411 次
发布时间:2019-03-06

本文共 1711 字,大约阅读时间需要 5 分钟。

先看下效果

纯透明的pane,然后设置一个半透明的图片,可以看出来显示了父控件的button

看代码

public partial class PanelEx : Panel    {        protected Graphics graphics;        protected override CreateParams CreateParams        {            get            {                CreateParams cp = base.CreateParams;                cp.ExStyle |= 0x00000020; // 实现透明样式                return cp;            }        }        public PanelEx()        {            InitializeComponent();            this.BackColor = Color.Transparent;            this.ForeColor = Color.Transparent;        }        protected override void OnPaintBackground(PaintEventArgs pevent)        {        }        protected override void OnPaint(PaintEventArgs e)        {            base.OnPaint(e);            this.graphics = e.Graphics;            this.graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;            this.graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;            this.graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;            this.graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;            this.graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;            if (this.BackgroundImage != null)            {                int width = this.Width;                int height = this.Height;                Rectangle recModel = new Rectangle(0, 0, width, height);                this.graphics.DrawImage(this.BackgroundImage, recModel);            }            else if (this.ForeColor != Color.Transparent)            {                this.graphics.Clear(this.ForeColor);            }        }    }
View Code

 

转载地址:http://tnvkz.baihongyu.com/

你可能感兴趣的文章
MySQL自定义变量?学不废不收费
查看>>
MySQL自带information_schema数据库使用
查看>>
MySQL获取分组后的TOP 1和TOP N记录
查看>>
mysql虚拟列表_动态网页制作-官方版合集下载-多特
查看>>
MySQL蜜罐反制获取攻击者信息
查看>>
Mysql表创建外键报错
查看>>
mysql表格调取数据库信息_MySQL™ 参考手册(获取有关数据库和表的信息)
查看>>
mysql表检查分析优化
查看>>
WARN: Establishing SSL connection without server‘s identity verification is not recommended.
查看>>
MySQL要点总结二
查看>>
Mysql覆盖索引
查看>>
mysql视图
查看>>
MySQL视图
查看>>
MySQL视图
查看>>
Mysql视图、变量、存储过程、函数
查看>>
Mysql视图、触发器、事务、储存过程、函数
查看>>
MySQL视图与索引详解
查看>>
mysql视图建立MERGE算法和TEMPTABLE算法的区别(效率与表锁定问题)
查看>>
mysql视图,索引和存储过程
查看>>
mysql解压没有data_Windows 64 位 mysql 5.7以上版本包解压中没有data目录和my-default.ini及服务无法启动的快速解决办法(问题小结)...
查看>>