Question

I'm trying to build a TableLayoutPanel on a WinForm and want it to behave exactly like a plain old HTML table.

One requirement is that this table needs to be built programmatically. This is what I have so far:

foreach (var RowLinq in ResultLinq)
{
    RichTextBox RT = new RichTextBox();
    RT.BorderStyle = BorderStyle.None;
    RT.Text = RowLinq.Result.ResultName;
    RT.Dock = DockStyle.Fill;

    TableLayoutPanel.RowCount++;
    TableLayoutPanel.RowStyles.Add(new RowStyle(System.Windows.Forms.SizeType.AutoSize));
    TableLayoutPanel.Controls.Add(rt1, 0, tableLayoutPanel5.RowCount - 1);
}

So this builds a row for each row in my Linq result. This works pretty well except for one thing: the height doesn't adjust at all and is completely fixed. I need the height to grow and shrink depending on the height of the text inside each cell.

I need your help with this one big time, thanks Stack-o

Was it helpful?

Solution

Set its AutoSize property to True.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top