开发者

Transparent background for a control

I'm developing a winforms application (using .NET 3.5)

In a form I have a panel control ,and a datagridview control inside of it .

I want to have some control ( let's say for the simplicity - a label) to appear in front of the datagridview , and I want this label to be transparent - which means : I want to see the data displayed in the gridview behind .

I just want to see the text that is in the label , but not the whole rectangle .. and behind that text - to see the data I have in the gridview.

The problem is the following : the parent contr开发者_如何学Gool of the label is not the gridview (since it's not a container control ) . The parent of the label , is the panel control .

So when I set the label to be transparent .. I actually get transparency to the panel , and not to the datagridview.


Check out this CodeProject article: How to Use Transparent Images and Labels in Windows Forms

Also, you could always use GDI (System.Drawing) and just draw what you want directly onto a transparent panel?


Set the panel to also be transparent. It shouldn't cause any trouble with the panel, since you'll still have the form itself behind it.

There is one other issue to warn you about as well. Transparency in winforms controls is only simulated or faked, in that when you create the control it takes an image of the form behind the control and uses that for the background, rather than truly making it transparent. This can cause issues if that background changes or the controls moves around on the form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜