TableLayoutColumnStyleCollection TableLayoutColumnStyleCollection TableLayoutColumnStyleCollection TableLayoutColumnStyleCollection Class

定义

一个存储 ColumnStyle 对象的集合。A collection that stores ColumnStyle objects.

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
继承
TableLayoutColumnStyleCollectionTableLayoutColumnStyleCollectionTableLayoutColumnStyleCollectionTableLayoutColumnStyleCollection

示例

下面的示例演示如何设置ColumnStyleTableLayoutColumnStyleCollectionThe following example shows how to set ColumnStyle for a TableLayoutColumnStyleCollection. 此代码示例是为提供一个更大示例的一部分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

注解

TableLayoutColumnStyleCollection类表示用于描述中关联的列的所有样式的集合TableLayoutPanelThe TableLayoutColumnStyleCollection class represents the collection of all the styles used to describe the columns in an associated TableLayoutPanel.

属性

Count Count Count Count

获取中实际包含的样式数量TableLayoutStyleCollectionGets the number of styles actually contained in the TableLayoutStyleCollection.

(Inherited from TableLayoutStyleCollection)
ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

此方法的说明,请参阅IsSynchronized属性。For a description of this method, see the IsSynchronized property.

(Inherited from TableLayoutStyleCollection)
ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

此方法的说明,请参阅SyncRoot属性。For a description of this method, see the SyncRoot property.

(Inherited from TableLayoutStyleCollection)
IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

此方法的说明,请参阅IsFixedSize属性。For a description of this method, see the IsFixedSize property.

(Inherited from TableLayoutStyleCollection)
IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

此方法的说明,请参阅IsReadOnly属性。For a description of this method, see the IsReadOnly property.

(Inherited from TableLayoutStyleCollection)
IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

此方法的说明,请参阅Item[Int32]属性。For a description of this method, see the Item[Int32] property.

(Inherited from TableLayoutStyleCollection)
Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取或设置指定索引处的 ColumnStyleGets or sets the ColumnStyle at the specified index.

方法

Add(ColumnStyle) Add(ColumnStyle) Add(ColumnStyle) Add(ColumnStyle)

将某项添加到 TableLayoutColumnStyleCollection 中。Adds an item to the TableLayoutColumnStyleCollection.

Add(TableLayoutStyle) Add(TableLayoutStyle) Add(TableLayoutStyle) Add(TableLayoutStyle)

添加一个新TableLayoutStyle到当前集合的末尾。Adds a new TableLayoutStyle to the end of the current collection.

(Inherited from TableLayoutStyleCollection)
Clear() Clear() Clear() Clear()

取消关联的集合及其关联的TableLayoutPanel并清空该集合。Disassociates the collection from its associated TableLayoutPanel and empties the collection.

(Inherited from TableLayoutStyleCollection)
Contains(ColumnStyle) Contains(ColumnStyle) Contains(ColumnStyle) Contains(ColumnStyle)

确定指定的 ColumnStyle 是否在集合中。Determines whether the specified ColumnStyle is in the collection.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IndexOf(ColumnStyle) IndexOf(ColumnStyle) IndexOf(ColumnStyle) IndexOf(ColumnStyle)

确定 TableLayoutColumnStyleCollection 中特定项的索引。Determines the index of a specific item in the TableLayoutColumnStyleCollection.

Insert(Int32, ColumnStyle) Insert(Int32, ColumnStyle) Insert(Int32, ColumnStyle) Insert(Int32, ColumnStyle)

ColumnStyle 插入指定位置的 TableLayoutColumnStyleCollectionInserts a ColumnStyle into the TableLayoutColumnStyleCollection at the specified position.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(ColumnStyle) Remove(ColumnStyle) Remove(ColumnStyle) Remove(ColumnStyle)

ColumnStyle 中移除特定 TableLayoutColumnStyleCollection 的第一个匹配项。Removes the first occurrence of a specific ColumnStyle from the TableLayoutColumnStyleCollection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

删除集合的指定索引处的样式。Removes the style at the specified index of the collection.

(Inherited from TableLayoutStyleCollection)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

此方法的说明,请参阅CopyTo(Array, Int32)方法。For a description of this method, see the CopyTo(Array, Int32) method.

(Inherited from TableLayoutStyleCollection)
IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

此方法的说明,请参阅GetEnumerator()方法。For a description of this method, see the GetEnumerator() method.

(Inherited from TableLayoutStyleCollection)
IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

此方法的说明,请参阅Add(Object)方法。For a description of this method, see the Add(Object) method.

(Inherited from TableLayoutStyleCollection)
IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

此方法的说明,请参阅Contains(Object)方法。For a description of this method, see the Contains(Object) method.

(Inherited from TableLayoutStyleCollection)
IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

此方法的说明,请参阅IndexOf(Object)方法。For a description of this method, see the IndexOf(Object) method.

(Inherited from TableLayoutStyleCollection)
IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

此方法的说明,请参阅Insert(Int32, Object)方法。For a description of this method, see the Insert(Int32, Object) method.

(Inherited from TableLayoutStyleCollection)
IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

此方法的说明,请参阅Remove(Object)方法。For a description of this method, see the Remove(Object) method.

(Inherited from TableLayoutStyleCollection)

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

将转换IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅