ColumnStyle Class


Represents the look and feel of a column in a table layout.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Public Class ColumnStyle
	Inherits TableLayoutStyle


Initializes and instance of the ColumnStyle class to its default state.


Initializes an instance of the ColumnStyle class using the supplied SizeType value.

System_CAPS_pubmethodColumnStyle(SizeType, Single)

Initializes and instance of the ColumnStyle class using the supplied SizeType and width values.


Gets or sets a flag indicating how a row or column should be sized relative to its containing table.(Inherited from TableLayoutStyle.)


Gets or sets the width value for a column.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

The ColumnStyle class represents the user interface (UI) characteristics of column in a TableLayoutPanel. The styles for all the columns in such a table are collected in the TableLayoutPanel.ColumnStyles property.

This simple class offers the Width and SizeType properties for a column.

The following code example demonstrates how to extract a ColumnStyle from a TableLayoutColumnStyleCollection.

This code example is part of a larger example provided for the TableLayoutPanel class.

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

    Dim styles As TableLayoutColumnStyleCollection = _

    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


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

        End If


End Sub

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft