TableLayoutColumnStyleCollection 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
用于存储 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
- 继承
下面的示例演示如何为 a TableLayoutColumnStyleCollection设置 ColumnStyle 。 此代码示例是为控件提供的大型示例的 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(Column |
将某项添加到 TableLayoutColumnStyleCollection 中。 |
Add(Table |
在当前集合的末尾添加一个新的 TableLayoutStyle。 (继承自 TableLayoutStyleCollection) |
Clear() |
断开集合与关联的 TableLayoutPanel 之间的关联,并清空该集合。 (继承自 TableLayoutStyleCollection) |
Contains(Column |
确定指定的 ColumnStyle 是否在集合中。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Index |
确定 TableLayoutColumnStyleCollection 中特定项的索引。 |
Insert(Int32, Column |
将 ColumnStyle 插入指定位置的 TableLayoutColumnStyleCollection。 |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
Remove(Column |
从 ColumnStyle 中移除第一次出现的特定 TableLayoutColumnStyleCollection。 |
Remove |
移除集合的指定索引处的样式。 (继承自 TableLayoutStyleCollection) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
Cast<TResult>(IEnumerable) |
将 IEnumerable 的元素强制转换为指定的类型。 |
Of |
根据指定类型筛选 IEnumerable 的元素。 |
As |
启用查询的并行化。 |
As |
将 IEnumerable 转换为 IQueryable。 |
产品 | 版本 |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
Windows Desktop | 3.0, 3.1, 5, 6, 7 |