C# 中的重叠面板
我正在使用 C# 中的 GUI 表单生成器。 我设置了一个 TransparencyKey,并且整个表单的背景颜色设置为该 Transparency 键,因此表单的背景看起来不可见。 我还有一个登录面板,首先出现,用户登录后它消失,其他面板变得可见。 除非我尝试重叠任何面板,否则这一切都有效。 发送到后面或带到前面没有区别。 如果其中一个面板有一点重叠,那么这两个重叠的面板都会消失吗? 可能出什么问题了?
干杯 授予
I am using the GUI forms builder in c#. I have a TransparencyKey set, and the backGround color of the whole form is set to that Transparency key so the background of the form seems invisible. I also have a login panel that appears at first and after the user logs in it disappears and the other panels become visible. This all works except when I attempt to overlap any of the panels. Send to back or bring to front make no difference. If even one of the panels overlap a little both of those overlapping panels disappear? What could be wrong?
Cheers
Grant
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这是 WinForms,则根本不存在 Z 顺序的概念。 每个面板都会要求父窗体绘制其背景。 因此,WinForms 透明度很少能如您所期望的那样发挥作用。
话虽如此,我不明白为什么如果有任何重叠,面板会完全消失。 我过去曾实施过此类事情,但从未见过这种行为。 您可以在一个非常小的示例项目中重新创建它并发布代码吗?
If this is WinForms, there is no concept at all of a Z-Order. Each panel will ask the parent form to paint it's background. For this reason, WinForms transparency seldom works as you would expect.
Having said that, I don't see why the panels would disappear entirely if there is any overlap. I have implemented this type of thing in the past and never seen that behavior. Can you recreate this in a very small sample project and post the code?
不确定我所说的是否适用于您正在做的事情。 今天我试图用我的窗口窗体中的面板做类似的事情。 我有两个面板,我想根据数据绑定控件切换它们的可见性。 PanelX 可见,而 PanelY 不可见。 嗯,我遇到了一个问题...PanelX 是可见的,PanelY 是不可见的。 但是,如果我将表单输入更改为 PanelY 应可见且 PanelX 应不可见,则它们都是不可见的。 无论我做什么,我都无法让 PanelY 可见。
好吧,解决方案是这样的。 我已将 PanelY 放置在 PanelX 中(当然没有意识到我这样做了)。 我想要的是 PanelX 和 PanelY 都位于主窗体容器上。 但就像我说的,PanelY 在 PanelX 的容器内......所以当 PanelX 不可见并且 PanelY 应该可见时,PanelY 也是不可见的,因为它的容器(PanelX)是不可见的。
长话短说,请确保您的面板位于正确的容器中。
Not sure if what I'll say will apply to what you're doing. I was trying to do something similar today with panels in my windows form. I had two panels that I wanted to toggle their visibility based on a databound control. PanelX would be visible while PanelY was invisible. Well I was getting a problem... PanelX would be visible and PanelY would be invisible. But if I changed the form inputs to where PanelY should be visible and PanelX should be invisible, they were both invisible. I could not get PanelY to be visible no matter what I did.
Well the solution was this. I had placed PanelY inside PanelX (not realizing that I did of course). What I wanted was PanelX and PanelY to both be on the main form container. But like I said, PanelY was inside PanelX's container... so when PanelX was invisible and PanelY should have been visible, PanelY was also invisible because it's container (PanelX) was invisible.
So long story short, make sure your Panel's are in the proper container.