C# winform怎么让pictruebox在其他控件上面背景透明
2018-02-06 14:54
477 查看
在MSDN中:
Transparent controls in WinForms are transparent relative to their parent, not to other controls. Transparency in WinForms is more akin to camouflage than true transparency. A transparent control doesn’t actually let you see the control behind it through the form. It asks its parent to draw its own background on the "transparent" control. This is why a transparent control shows the form behind it, but covers up any other controls.
方法一:所以图片绘制在一起。
在Winform中如果将一个透明图片放在窗体上能正常显示透明,但是如果将该图片放在另一个控件上会导致不能显示透明效果。
解决这种情况,可以采取在控件上使用GDI+绘画出透明图片。
这里我们就以一个pictureBox2控件上面重叠一张png透明图片为例:
我们只需要给pictureBox2控件添加Paint事件,然后对png透明图片进行绘制即可,代码如下:
?
方法二:底层图片绘制在一起。
将控件作为父控件的一部分进行绘图,并作为背景。此时再加入透明图片,即可看到透明效果。即如果要后面显示控件。那还得把控件画进去 背景显示。
Transparent controls in WinForms are transparent relative to their parent, not to other controls. Transparency in WinForms is more akin to camouflage than true transparency. A transparent control doesn’t actually let you see the control behind it through the form. It asks its parent to draw its own background on the "transparent" control. This is why a transparent control shows the form behind it, but covers up any other controls.
方法一:所以图片绘制在一起。
在Winform中如果将一个透明图片放在窗体上能正常显示透明,但是如果将该图片放在另一个控件上会导致不能显示透明效果。
解决这种情况,可以采取在控件上使用GDI+绘画出透明图片。
这里我们就以一个pictureBox2控件上面重叠一张png透明图片为例:
我们只需要给pictureBox2控件添加Paint事件,然后对png透明图片进行绘制即可,代码如下:
?
将控件作为父控件的一部分进行绘图,并作为背景。此时再加入透明图片,即可看到透明效果。即如果要后面显示控件。那还得把控件画进去 背景显示。
相关文章推荐
- C# 解决panel或者其他控件叠加时,此控件背景透明,显示的背景色为窗体背景色问题
- C#中实现真正的透明的PictrueBox
- C# PicBox 背景透明
- vc static控件背景设置成透明(其他控件也可以)
- AS3 PictrueBox控件 ---- 使用水平、垂直滚动条的图片框
- 在MFC对话框中,如何让控件Static和Radio和CheckBox背景透明?
- pictrueBox带保存图片
- 【转】自行实现透明的控件如Panel GroupBox
- 实现控件的透明背景
- MFC设置Static控件背景透明
- Android给TextView和EditText等控件设置透明背景、圆角边框
- 改变navigationBar的背景导致其他控件被覆盖
- C# WinForm 给某动态控件设置 IsBalloon = true的ToolTip 即 气泡状提示
- MFC 加入背景图片并让控件背景透明
- 关于控件的背景透明
- DIV在FLASH上面、FLASH透明背景
- MFC设置控件背景透明
- 5.VC(ui)-背景透明的static控件
- C#中OpenFileDialog和PictrueBox的用法分析
- C# winform 布局,最大化之后再还原,内部其他控件大小怎么随着变化。