Reputation: 3
I'm in the process of developing a C# Winforms application. I have divided the form into table cells using a TableLayoutPanel. For a particular cell of the table layout, I want to insert multiple panels - one over another, so that I can switch between panels(for that cell only) using BringToFront().
I tried the same on a form which seemed to work. In the cell of table layout, I am only able to add one panel into it. When I try to add other panels in that cell, these get embedded into the first panel. This makes it difficult to switch between panels.
I also tried inserting all the required panels into an empty panel(placed in the cell). But then, I'm not able to figure out how to switch among it's child panels.
Note: The switching of the panels is to be triggered by a ComboBox selection in some other cell of the table.
Upvotes: 0
Views: 788
Reputation: 2082
If you want to switch between panels, thats will always go wrong, because the bottom panel will become the parent of the top one... @Hans Passant give a solution in another topic and citing:
This can be worked around with View > (Other Windows) > Document Outline, drag the top panel back to the form. Still pretty painful, you typically have to edit the Location by hand and making any changes to the form in the designer later tends to slurp the panel back.
There are better ways to do this. Creating UserControls instead is highly recommended, they have their own design surface. Or use the RAD way and do this with a TabControl instead
Full Credits: Credits
Upvotes: 1