如何在其他两个已经存在的面板之上创建一个透明的System.Windows.Forms.Panel,然后在我的透明面板上绘制一条线? [英] How can I create a transparent System.Windows.Forms.Panel on top of two other already existing Panels then draw a line on my transparent panel?

查看:240
本文介绍了如何在其他两个已经存在的面板之上创建一个透明的System.Windows.Forms.Panel,然后在我的透明面板上绘制一条线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#编写一个表单,并且有多个面板.我需要在两个面板之间画一条线.我在网上发现了几种解决方法,最有前途的似乎是创建第三个面板,使其透明,将其放置在原始面板的顶部,然后在此处画线.

I'm writing a form in C# and have several panels. I need to draw a line between two of the panels. I've found online several ways to go about this, the most promising appears to be to create a third panel, make it transparent, place it on top of my original panels and draw the line here.

即使将面板的BackColor和ForeColor属性设置为透明(在代码或VS的设计视图中),我也无法使面板透明.

I'm not able to get the panel to be transparent, even if I set its BackColor and ForeColor properties to transparent (in code or in design view of VS).

关于如何使面板本身透明(或不可见)的任何想法,但我在面板上绘制的线条是否仍在其他所有内容之上可见?

Any ideas on how to make the panel itself transparent (or not Visible) but have the line I draw on it still visible on top of everything else?

谢谢.

推荐答案

不,它是透明的.通过给表单的BackgroundImage一个值来查看此内容.您将通过透明面板看到它.当然,这不是您想要的那种透明度,而是希望叠加效果起作用.没有直接的支持.

No, it's transparent. See this by giving the form's BackgroundImage a value. You'll see it through the transparent panel. Of course, that's not the kind of transparency you want, you want stacking effects to work. There is no direct support for that.

如果您希望图层起作用,请不要使用控件.使用Paint事件进行绘制.现在没有问题了,如果您想要透明度,那就不要绘画.只需先绘制图像,即可在图像上画一条线.这也是WPF的渲染模型.

If you want layers to work then don't use controls. Use the Paint event to draw. Now there's no problem, if you want transparency then just don't paint. Draw a line across an image simply by drawing the image first. This is also the rendering model of WPF.

这篇关于如何在其他两个已经存在的面板之上创建一个透明的System.Windows.Forms.Panel,然后在我的透明面板上绘制一条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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