TableLayoutPanel.GetColumn(Control) Method

Definition

Returns the column position of the specified child control.

public int GetColumn (System.Windows.Forms.Control control);

Parameters

control
Control

A child control of the TableLayoutPanel.

Returns

The column position of the specified child control, or -1 if the position of control is determined by LayoutEngine.

Exceptions

control is null.

control is not a type that can be arranged by this LayoutEngine.

Examples

The following code example enumerates all the child controls in the TableLayoutPanel and finds the column index for each control using the GetColumn method.

private void getColumnBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    foreach ( Control c in this.TableLayoutPanel1.Controls )
    {
        Trace.WriteLine(this.TableLayoutPanel1.GetColumn(c));
    }
}

Remarks

If control spans two or more columns, the GetColumn method will return the lowest column index.

The column position value is zero based, so you can use it as an index for the array returned by GetColumnWidths.

This method is called by the Column property, which the panel adds to its child controls at design time.

To get the actual position of control, even when its position is determined by LayoutEngine, call the GetPositionFromControl method.

Applies to

Өнім Нұсқалар
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also