C#自定义控件背景透明
2011-08-10 15:23
134 查看
在自定义控件中加入以下代码:
public errorProvider()
{
InitializeComponent();
SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor |
ControlStyles.Selectable |
ControlStyles.ResizeRedraw, true);
this.BackColor = Color.Transparent;
}
这样自定义的控件,就实现了背景透明。
经过测试有点问题:
在panel上使用此类控件没有问题。但是如果panel上面有个picturebox的话,该控件放在picturebox上,此控件那部分会显示panel的背景颜色而把picturebox的图片挡住。
哪位高手要知道怎么修改代码,希望给点建议。
public errorProvider()
{
InitializeComponent();
SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor |
ControlStyles.Selectable |
ControlStyles.ResizeRedraw, true);
this.BackColor = Color.Transparent;
}
这样自定义的控件,就实现了背景透明。
经过测试有点问题:
在panel上使用此类控件没有问题。但是如果panel上面有个picturebox的话,该控件放在picturebox上,此控件那部分会显示panel的背景颜色而把picturebox的图片挡住。
哪位高手要知道怎么修改代码,希望给点建议。
相关文章推荐
- C# WinForm 自定义控件,DataGridView背景透明,TabControl背景透明
- c#把白色背景变成透明
- [C#] - 用户自定义控件(含源代码)-透明文本框
- C#叠加图片,背景为透明的
- C#设置label(标签)控件的背景颜色为透明
- C#把Lable的背景颜色设为透明
- C#Form窗体背景透明
- C# 用GDI在图片上写字实现lable透明背景
- C# 透明背景Panel, 透明图像, PitureBox透明效果
- C# 解决panel或者其他控件叠加时,此控件背景透明,显示的背景色为窗体背景色问题
- C#重写控件使其透明背景
- C# Winform中如何让PictureBox的背景透明
- C# 实现PNG文件的背景透明显示,解决动态显示闪烁问题 【转】
- C#中如何使PicturesBox控件上的Label控件背景透明
- c# 自定义控件透明,自定义透明窗体
- 如何在C#中播放AVI短片并使背景透明
- C#将图片白色背景设置为透明
- c#中怎么让正在播放的视频背景是透明的?
- 【安卓自定义控件】自定义ViewGroup实现透明背景的ViewPager效果
- 背景透明的ListBox(C#.WinForm)