I am using a TableLayoutPanel to split a client area into 3 rows. (There is only 1 column)The top and bottom rows are designed to be of fixed height; they will contain a header and a footer which initially each contain a child lable control that contain static text (just to start off with). The midde row should be dynamically sized to fill remaining area. This middle pane will eventually contain a listview. I have a manager class that takes as an argument the panel (ExplorerTableLayoutPanel) object being managed:
public class ExplorerTableLayoutPanelManager
{
public ExplorerTableLayoutPanelManager(ExplorerTableLayoutPanel panel)
{
LayoutPanel = panel;
}
There are 3 methods that create each of the 3 rows in the table layout:
private void AddHeaderRow()
{
const int headerHeight = 30;
LayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, headerHeight));
Label label = new Label();
label.BackColor = Color.AliceBlue;
label.BorderStyle = BorderStyle.None;
label.ForeColor = Color.LightGray;
label.TextAlign = ContentAlignment.MiddleRight;
label.Text = "Header Banner";
label.Dock = DockStyle.Fill;
float size = label.Font.SizeInPoints;
label.Font = new Font(label.Font.Name, size * 2);
const int column = 0, row = 0;
LayoutPanel.Controls.Add(label, column, row);
}
private void AddBodyRow()
{
LayoutPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
Label label = new Label();
label.BorderStyle = BorderStyle.FixedSingle;
label.ForeColor = Color.LightGray;
label.TextAlign = ContentAlignment.MiddleCenter;
label.Text = "Content Under construction ...";
label.Dock = DockStyle.Fill;
float size = label.Font.SizeInPoints;
label.Font = new Font(label.Font.Name, size * 2);
const int column = 0, row = 1;
LayoutPanel.Controls.Add(label, column, row);
}
private void AddFooterRoow()
{
const int footerHeight = 30;
LayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, footerHeight));
Label label = new Label();
label.BackColor = Color.AliceBlue;
label.BorderStyle = BorderStyle.None;
label.ForeColor = Color.LightGray;
label.TextAlign = ContentAlignment.MiddleRight;
label.Text = "Footer Banner";
label.Dock = DockStyle.Fill;
float size = label.Font.SizeInPoints;
label.Font = new Font(label.Font.Name, size * 2);
const int column = 0, row = 2;
LayoutPanel.Controls.Add(label, column, row);
}
The problem I am seeing is that the last row is taking up the fixed row hieght which i have requested as 30. This part is correct. However, the first and second rows are spliting the remaining space equally between them which is not what I want. As you can see, I have explicitly set the row height to 30 for the first row in exactly the same manner as done for the last row, but this deoesn't appear to work. The 2nd row (middle) has its RowStyle size set to SizeType.AutoSize which I though was meant to mean use up the remaining space, so don't explicitly set the size. I may be wrong but I'm not sure.
Any help would be most appreciated,
regards.