TableLayoutColumnStyleCollection 类

定义

存储 ColumnStyle 对象的集合。

public ref class TableLayoutColumnStyleCollection : System::Windows::Forms::TableLayoutStyleCollection
public class TableLayoutColumnStyleCollection : System.Windows.Forms.TableLayoutStyleCollection
type TableLayoutColumnStyleCollection = class
    inherit TableLayoutStyleCollection
Public Class TableLayoutColumnStyleCollection
Inherits TableLayoutStyleCollection
继承
TableLayoutColumnStyleCollection

示例

以下示例演示如何为 a ColumnStyle.TableLayoutColumnStyleCollection 此代码示例是为控件提供的大型示例的 TableLayoutPanel 一部分。

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

注解

TableLayoutColumnStyleCollection 表示用于描述关联 TableLayoutPanel列的所有样式的集合。

属性

名称 说明
Count

获取实际包含在 . 中的 TableLayoutStyleCollection样式数。

(继承自 TableLayoutStyleCollection)
Item[Int32]

获取或设置 ColumnStyle 指定索引处。

方法

名称 说明
Add(ColumnStyle)

将项添加到 TableLayoutColumnStyleCollection

Add(TableLayoutStyle)

将新 TableLayoutStyle 添加到当前集合的末尾。

(继承自 TableLayoutStyleCollection)
Clear()

将集合与关联的 TableLayoutPanel 集合取消关联,并清空集合。

(继承自 TableLayoutStyleCollection)
Contains(ColumnStyle)

确定指定的 ColumnStyle 是否在集合中。

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
IndexOf(ColumnStyle)

确定 TableLayoutColumnStyleCollection中特定项的索引。

Insert(Int32, ColumnStyle)

将 a ColumnStyleTableLayoutColumnStyleCollection 插入到指定位置。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
Remove(ColumnStyle)

从中删除特定ColumnStyleTableLayoutColumnStyleCollection项的第一个匹配项。

RemoveAt(Int32)

删除集合的指定索引处的样式。

(继承自 TableLayoutStyleCollection)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
ICollection.CopyTo(Array, Int32)

有关此方法的说明,请参阅该方法 CopyTo(Array, Int32)

(继承自 TableLayoutStyleCollection)
ICollection.IsSynchronized

有关此方法的说明,请参阅 IsSynchronized 属性。

(继承自 TableLayoutStyleCollection)
ICollection.SyncRoot

有关此方法的说明,请参阅 SyncRoot 属性。

(继承自 TableLayoutStyleCollection)
IEnumerable.GetEnumerator()

有关此方法的说明,请参阅该方法 GetEnumerator()

(继承自 TableLayoutStyleCollection)
IList.Add(Object)

有关此方法的说明,请参阅该方法 Add(Object)

(继承自 TableLayoutStyleCollection)
IList.Contains(Object)

有关此方法的说明,请参阅该方法 Contains(Object)

(继承自 TableLayoutStyleCollection)
IList.IndexOf(Object)

有关此方法的说明,请参阅该方法 IndexOf(Object)

(继承自 TableLayoutStyleCollection)
IList.Insert(Int32, Object)

有关此方法的说明,请参阅该方法 Insert(Int32, Object)

(继承自 TableLayoutStyleCollection)
IList.IsFixedSize

有关此方法的说明,请参阅 IsFixedSize 属性。

(继承自 TableLayoutStyleCollection)
IList.IsReadOnly

有关此方法的说明,请参阅 IsReadOnly 属性。

(继承自 TableLayoutStyleCollection)
IList.Item[Int32]

有关此方法的说明,请参阅 Item[Int32] 属性。

(继承自 TableLayoutStyleCollection)
IList.Remove(Object)

有关此方法的说明,请参阅该方法 Remove(Object)

(继承自 TableLayoutStyleCollection)

扩展方法

名称 说明
AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

适用于

另请参阅