为picturebox或面板设置transperentr背景 [英] set transperentr background for picturebox or panel

查看:51
本文介绍了为picturebox或面板设置transperentr背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户控件,背景颜色为黑色,有3个图像。

第一个是整个用户控件,第二个是usercontrol的底部,最后一个是第二个图像,带有transperent背景它是.png图像,但现在当我为它设置背景transprent它总是显示黑色

任何人都可以告诉我如何将它设置为黑色?

I have a user control which background color is black and there 3 images.
1st one is on entire usercontrol and 2nd one is bottom part of usercontrol and last one is on second image with transperent background it is .png image but now when i set background transprent for it it always shows black
can any one tell me how to set it to black??

推荐答案

如果它是透明的,它不是真正的黑色。 :-)



如果你认为什么是透明度,你会明白这个概念是一种比喻。只有在透明图形下显示某些内容才有意义。而且,只有有一些动作才有严格意义。您移动顶部对象并观察下面的对象。您需要考虑是否希望表单是透明的,并查看其下的不同应用程序的窗口。



这就是说,你应该明白控制的透明度 System.Windows.Forms 不支持。如果你需要灵活和先进的东西,切换到WPF,不要浪费时间,或放弃。如果你有一些限制,考虑在一个自定义控件中渲染GDI对象;这将完美地运作。当然,甚至不考虑使用 PictureBox ;这根本没有意义。请看我过去的一些答案:

如何从旧图纸中清除面板 [ ^ ],

在C#中绘制一个矩形 [ ^ ],

在图片框中附加图片 [ ^ ];

参见:

在mdi子表单之间绘制线条[ ^ ],

捕捉面板上的图纸 [ ^ ],

什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],

如何加速我的vb.net应用程序? [ ^ ]。



-SA
If it is transparent, it''s not really black. :-)

If you think what is transparency, you will understand that this concept is a kind of metaphor. It only makes sense if you have something to show under a "transparent" graphics. Moreover, it has strict sense only if there is some motion. You move top object and observe the objects underneath. You need to think if you want a form to be transparent, and see the windows of the different applications under it.

That said, you should understand that transparency of control is not well supported by System.Windows.Forms. If you need something flexible and advanced, switch to WPF, don''t waste time of Forms, or give it up. If you have something limited, think about rendering of GDI objects in one custom control; this will work perfectly. And of course, don''t even think about using PictureBox; it makes no sense at all. Please see some of my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^];
see also:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
How to speed up my vb.net application?[^].

—SA


这篇关于为picturebox或面板设置transperentr背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆