简体   繁体   中英

Overlapping Panels in C#

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

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM