Home

Accessories for Control Design: The Table Layout Panel

     

Introduction

During your application design, if you have a group of controls that you want to align either horizontally or vertically, you can use the flow layout panel. You can use different rows and columns of flow layout panels to align the controls. If you do this, you would then have to align the flow layout panels also to make sure their controls are aligned.

 

In reality, the flow layout panel is a valuable accessory for control design but it may not effectively align different types of controls. To assist with another type of problem, you can use the table layout panel.

The table layout panel is represented in the .NET Framework by the TableLayoutPanel class and in the Toolbox by the TableLayoutPanel control. To use it at design time, from the Toolbox, click the TableLayoutPanel button and click the form. When it has been added, it presents a dotted table made of four cells:

When it has been added, the table layout panel presents a dotted rectangle made of four cells

 

To use the table layout panel as a design object, you can click a control from the Toolbox and click a cell in the table. The control would be added to that cell. To add another control to the application, you can click it from the Toolbox and click another cell:

To use the table layout panel as a design object, you can click a control from the Toolbox and click a cell in the table. The control would be added to that cell. To add another control to the application, you can click it from the Toolbox and click another cell

Characteristics of a Table Layout

You cannot add a control to a cell if that cell contains a control already. If you want to add more controls than the cells in the table layout panel, you can add new cells. To do this, first select the table layout panel from the form:

  • To add a new column, under the Properties window, you can click Add Column
  • To add a row, under the Properties window, you can click Add Row
  • To add more than one column or more than one row, in the Properties window, click Columns or Rows and click its ellipsis button. This would open the Column and Row Style dialog box
     
    Column and Row Styles
     
    To add a column, in the Show combo box, select Columns and click Add. To add a row, in the Show combo box, select Rows and click Add. After using the dialog box, you can click OK

Besides the ability to align the controls, the table layout panel provides various aesthetic characteristics, such as the background color of the table, various styles for the dividing lines of the cells, etc.

 

Home Copyright © 2010-2016, FunctionX