Reputation: 814
I have a TableLayoutPanel
containing 5 rows and 5 columns with variable sizes (a 3x3 grid with filler cells on the sides). In each of the inner cells, I put a PictureBox
with the Dock
parameter set on Fill
. I now want to add a Label
that would cover the entirety of those 9 cells. Since the Label
is transparent and not always visible, there should be no issues with this.
But when I try to move the Label
in the TableLayoutPanel
, all it does is "compress" the PictureBoxes
on the bottom or on the right.
Here is a before/after set of pictures :
(the text in white is a part of the program, not a caption)
I have tried modifying the RowSpan
and ColumnSpan
properties of the label, but to no avail. As of now the Dock
properties of the PictureBoxes
is set on Fill
, and so is the Label
. Setting it to None
only makes it smaller, but leaves the PictureBoxes
stacked at the bottom.
I have also tried modifying the TabIndexes
but had no luck with this either.
How can I achieve what I want?
Upvotes: 3
Views: 4193
Reputation: 814
The solution, as Sinatr pointed out, is to create a container like a Panel
and make it contain both overlapping controls (here, the PictureBox
and the TableLayoutPanel
containing the 9 other PictureBoxes
), since a TableLayoutPanel
can only contain one element per cell.
The structure of the document must look like this:
Form
↳ Panel
↳ PictureBox # The big one
↳ TableLayoutPanel
↳ PictureBox # The 9 small ones
...
↳ PictureBox
Upvotes: 3