I'm trying to make the middle column of a 3-column TableLayoutPanel expandable. I'm doing it everything from code, not the designer, as a learning exercise.
The middle column has a text box and the left and right columns have a button each:
As you can see from the screenshot, the 2nd column is not expandable yet.
I'm following the advice from https://stackoverflow.com/a/22283690/492336 - I set the TextBox control's Dock to Fill, and also the panel's Dock to Fill as well:
var panel = new TableLayoutPanel();
panel.RowCount = 1;
panel.ColumnCount = 3;
panel.Controls.Add(new Button());
panel.Controls.Add(new TextBox());
panel.Controls.Add(new Button());
panel.Controls[0].Text = "Button1";
panel.Controls[2].Text = "Button2";
panel.Controls[1].Dock = DockStyle.Fill;
panel.Dock = DockStyle.Fill;
I also tried the suggestion from https://stackoverflow.com/a/7279996/492336 by setting the columns to AutoSize:
panel.ColumnStyles.Clear();
panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
But that had no effect as well.
What am I doing wrong here?
