Share via


TableLayoutPanel.ColumnStyles Özellik

Tanım

için TableLayoutPanelsütun stilleri koleksiyonunu alır.

public:
 property System::Windows::Forms::TableLayoutColumnStyleCollection ^ ColumnStyles { System::Windows::Forms::TableLayoutColumnStyleCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.TableLayoutColumnStyleCollection ColumnStyles { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ColumnStyles : System.Windows.Forms.TableLayoutColumnStyleCollection
Public ReadOnly Property ColumnStyles As TableLayoutColumnStyleCollection

Özellik Değeri

TableLayoutColumnStyleCollection Denetimdeki TableLayoutPanel her sütun için bir ColumnStyle içeren.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, tıklandığında Button her sütunun özelliklerini ayarlarColumnStyle.

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

Açıklamalar

Belirli sütunların ColumnStyles stil özelliklerine erişmek için özelliğini kullanın. Tablodaki ColumnStyle tek tek sütunların özelliklerini ayarlamak için sınıfın üyelerini kullanabilirsiniz.

TableLayoutPanel Denetim sütunlarını düzenlediğinde, her ColumnStyle birine aşağıdaki sırayla öncelikleri atar:

  1. ColumnStyle olarak ayarlanmış Absolute sütunlar ilk olarak kabul edilir ve sabit genişlikleri ayrılır.

  2. ColumnStyle olarak ayarlanmış AutoSize sütunlar, içeriklerine göre boyutlandırılır.

  3. Kalan alan, olarak ayarlanmış Percentsütunlar ColumnStyle arasında bölünür.

Şunlara uygulanır

Ayrıca bkz.