Skip to content
cwensley edited this page Sep 23, 2011 · 11 revisions

The TableLayout is useful to align controls in a grid-like fashion. Rows and columns can be scaled to equally share the flexible space of the container. When a row or column is not scaled, it will only take up space necessary for the contained controls in that row and/or column.

The TableLayout can have padding to specify how much space should be added bounding the inner controls, and spacing to specify how much space should be allocated between each row/column.

Example

This example shows how you can create a table with 2 columns and 3 rows

var panel = new Panel();
var layout = new TableLayout(panel, 2, 3);  // creates a 2x3 table

// add some controls to the Panel using the table layout
layout.Add(new Label{ Text = "First Line" }, 0, 0);
layout.Add(new TextBox(), 1, 0);

layout.Add(new Label{ Text = "Second Line" }, 0, 1);
layout.Add(new ComboBox(), 1, 1);

layout.Add(new Label{ Text = "Third Line" }, 0, 2);
layout.Add(new ListBox(), 1, 2);