Export (0) Print
Expand All
Expand Minimize

SizeType Enumeration

Specifies how rows or columns of user interface (UI) elements should be sized relative to their container.

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

public enum SizeType

Member nameDescription
AbsoluteThe row or column should be sized to an exact number of pixels.
AutoSizeThe row or column should be automatically sized to share space with its peers.
PercentThe row or column should be sized as a percentage of the parent container.

The SizeType enumeration specifies how rows or columns of UI elements, typically controls, should be sized relative to the size of their container. This enumeration is used by the RowStyle and ColumnStyle classes to indicate their preferred sizing attributes. The TableLayoutPanel class, in turn, uses these style classes.

When laying out a container with rows or columns that have different preferred sizing attributes, any space remaining after the initial allocation will be distributed between the rows or columns whose styles have TableLayoutStyle.SizeType property values of AutoSize or Percent.

The following example shows how to set the TableLayoutStyle.SizeType property on a ColumnStyle object. This code example is part of a larger example provided for the TableLayoutPanel control.

    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

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft