SizeType SizeType SizeType SizeType Enum

定义

指定如何调整用户界面 (UI) 元素的行或列相对于其容器的大小。Specifies how rows or columns of user interface (UI) elements should be sized relative to their container.

public enum class SizeType
public enum SizeType
type SizeType = 
Public Enum SizeType
继承

字段

Absolute Absolute Absolute Absolute 1

行或列的大小应调整为确切的像素数。The row or column should be sized to an exact number of pixels.

AutoSize AutoSize AutoSize AutoSize 0

行或列的大小应自动调整,与其他行或列共享所有空间。The row or column should be automatically sized to share space with its peers.

Percent Percent Percent Percent 2

行或列应按父容器的百分比调整大小。The row or column should be sized as a percentage of the parent container.

示例

下面的示例演示如何设置TableLayoutStyle.SizeType属性上的ColumnStyle对象。The following example shows how to set the TableLayoutStyle.SizeType property on a ColumnStyle object. 此代码示例是为提供一个更大示例的一部分TableLayoutPanel控件。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;
          }
      }
  }
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

注解

SizeType枚举指定如何行或列的 UI 元素,通常为控件,应相对于其容器的大小调整。The SizeType enumeration specifies how rows or columns of UI elements, typically controls, should be sized relative to the size of their container. 此枚举由RowStyleColumnStyle类,以指示其首选大小调整属性。This enumeration is used by the RowStyle and ColumnStyle classes to indicate their preferred sizing attributes. TableLayoutPanel类,反过来,使用这些样式类。The TableLayoutPanel class, in turn, uses these style classes.

当对具有行或列具有不同的首选大小调整属性的容器进行布局,将分配初始分配后剩余的所有空间之间的行或列的样式具有TableLayoutStyle.SizeType属性值的自动调整大小或百分比。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.

适用于

另请参阅