Extended Properties with the Table LayoutPanel

The TableLayoutPanel also doubles as a property extender (by implementing IExtenderProvider). As a result, it adds virtual properties to all the child controls you place inside it. These properties are listed in Table 21-4.

Table 21-4. Extended Properties for TableLayoutPanel Children Property Description

Column Indicates the zero-based column index where the control is positioned.

You also can set this value programmatically to move a control to a new location in the table. If you move a control farther down a table, all the cells in between are left blank.

Row Indicates the zero-based row index where the control is positioned. You also can set this value programmatically to move a control to a new location in the table. If you move a control farther down a table, all the cells in between are left blank.

ColumnSpan Indicates the number of columns that this control spans (the default is 1).

For example, if you set ColumnSpan to 2, the control will occupy two cells (its own cell and the one on the right). If you specify a ColumnSpan greater than the number of columns on the right, the control is bumped to the next row. If you specify a ColumnSpan greater than the total number of columns in the table, the control occupies the entire row.

Table 21-4. Extended Properties for TableLayoutPanel Children

Property

Description

RowSpan Indicates the number of rows that this control spans (the default is 1). For example, if you set RowSpan to 2, the control will occupy two cells (its own cell and the one below it). If you specify a RowSpan greater than the number of rows below, the control is bumped to a new column.

CellPosition Provides a TableLayoutPanelCellPosition you can use to set both the Row and Column at once for optimum performance. In the Properties window, this extended property appears with the name Cell.

Figure 21-16 shows an example of cell spanning. Notice that if you set the TableLayoutPanel.CellBorderStyle to a value other than None, the control in the spanned cell is superimposed over the border. You can use column and row spanning simultaneously. In this case, the control fills a block of cells RowSpan x ColumnSpan in size. The layout panels are extremely flexible, and you can use them to create a wide range of effects. Unfortunately, it's not immediately obvious what approach you should take with the layout panels, and a property-by-property description does little to fill in the blanks. Instead, the following sections give you an example-based approach, leading you through common solutions that the layout panels can provide.

Tablelayoutpanel Rowspan
Figure 21-16. Row and column spanning
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment