Export (0) Print
Expand All

TableLayoutPanel.ColumnStyles Property

Gets a collection of column styles for the TableLayoutPanel.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

'Declaration
Public ReadOnly Property ColumnStyles As TableLayoutColumnStyleCollection
'Usage
Dim instance As TableLayoutPanel
Dim value As TableLayoutColumnStyleCollection

value = instance.ColumnStyles

/** @property */
public TableLayoutColumnStyleCollection get_ColumnStyles ()

public function get ColumnStyles () : TableLayoutColumnStyleCollection

Not applicable.

Property Value

A TableLayoutColumnStyleCollection containing a ColumnStyle for each column in the TableLayoutPanel control.

Use the ColumnStyles property to access the style properties of specific columns. You can use members of the ColumnStyle class to set the characteristics of individual columns in the table.

When the TableLayoutPanel control arranges its columns, it assigns priorities to each ColumnStyle in the following order:

  1. Columns with ColumnStyle set to Absolute are considered first, and their fixed widths are allocated.

  2. Columns with ColumnStyle set to AutoSize are sized to their contents.

  3. Remaining space is divided among columns with ColumnStyle set to Percent.

The following code example sets the ColumnStyle properties of each column when a Button is clicked.

Private Sub toggleColumnStylesBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles toggleColumnStylesBtn.Click

    Dim styles As TableLayoutColumnStyleCollection = _
    Me.TableLayoutPanel1.ColumnStyles

    For Each style As ColumnStyle In styles

        If style.SizeType = SizeType.Absolute Then

            style.SizeType = SizeType.AutoSize

        ElseIf style.SizeType = SizeType.AutoSize Then

            style.SizeType = SizeType.Percent

            ' Set the column width to be a percentage
            ' of the TableLayoutPanel control's width.
            style.Width = 33

        Else

            ' Set the column width to 50 pixels.
            style.SizeType = SizeType.Absolute
            style.Width = 50

        End If

    Next

End Sub

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft