ColumnStyle Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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)

System.Object
  System.Windows.Forms.TableLayoutStyle
    System.Windows.Forms.ColumnStyle

public class ColumnStyle : TableLayoutStyle

NameDescription
System_CAPS_pubmethodColumnStyle()

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

System_CAPS_pubmethodColumnStyle(SizeType)

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.

NameDescription
System_CAPS_pubpropertySizeType

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

System_CAPS_pubpropertyWidth

Gets or sets the width value for a column.

NameDescription
System_CAPS_pubmethodEquals(Object)

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

System_CAPS_protmethodFinalize()

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

System_CAPS_pubmethodGetHashCode()

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

System_CAPS_pubmethodGetType()

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

System_CAPS_protmethodMemberwiseClone()

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

System_CAPS_pubmethodToString()

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 void toggleColumnStylesBtn_Click(
System.Object sender, 
System.EventArgs e)
  {
TableLayoutColumnStyleCollection styles = 
	this.TableLayoutPanel1.ColumnStyles;

      foreach( ColumnStyle style in styles )
      {
          if( style.SizeType == SizeType.Absolute )
          {
              style.SizeType = SizeType.AutoSize;
          }
          else if( style.SizeType == SizeType.AutoSize )
          {
              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;
          }
      }
  }

.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
Show: