>I have a TableLayoutControl with 3 columns. At runtime, controls are added
>one at a time; they usually need to go into the next available cell, but
[quoted text clipped - 13 lines]
> this._container.SetRow(control, row);
> }
> I'm not sure what exactly you're trying to do, but maybe FlowLayoutPanel
> might solve your problem? It allows you to fill the panel with any controls,
> from left to right, with optional wrapping. You can also set "breaker
> controls", which cause a manual line break.
>
> Hope this helps a bit,
Unfortunately it doesn't, I need a grid layout.
By way of example,
align(Control[][] controls, TableLayoutPanel grid) {
foreach(Control[] row in controls)
foreach(Control control in row)
grid.Controls.Add(control);
}
The problem is that each row must begin a new line. To make things easier, the
TableLayoutPanel already has enough columns to accommodate the longest row, but
starts off with no rows. Unlike my trivial example, the rows are created on the
fly by reading a forward-only stream, so setting the number of rows in the grid
and using absolute positioning is not a solution of first resort.
Andrej Tozon - 01 Apr 2006 00:11 GMT
I created the following example, which adds controls to the grid, based on a
control grid array. Run it on a three-column tablelayoutpanel.
// Initialize sample control array
Control[][] controls = new Control[][]
{
new Control[] {new Button(), new Button(), new Button() },
new Control[] {new Button(), new Button() },
new Control[] {new Button()},
new Control[] {new Button(), new Button() },
new Control[] {new Button(), new Button(), new Button() }
};
int y = 0;
foreach(Control[] row in controls)
{
int x = 0;
foreach (Control control in row)
{
// Create control and add it to grid
grid.Controls.Add(control, x, y);
if (y < grid.RowCount)
{
grid.RowCount++;
}
x++;
}
y++;
}
Andrej
>> I'm not sure what exactly you're trying to do, but maybe FlowLayoutPanel
>> might solve your problem? It allows you to fill the panel with any
[quoted text clipped - 19 lines]
> of rows in the grid and using absolute positioning is not a solution of
> first resort.