views:

651

answers:

2

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

+1  A: 

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?

Eric J.
I see what you mean about z order. There is really no need to show you the code. If you were to simply create a form with a transparency key (and the background color set to that transparency key). If you try to put any panel on top of that it disappears. Without me ever even typing a key. I don't understand it. What I ended up doing was writing the code that creates the panel at runtime, and positions it based of where the form is currently located. For some reason this works, but creating them with the gui editor does not. Thanks for trying to help though.Grant-
cozmokramer8
A: 

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.

bryman222