ColumnStyle 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表表格版面中欄位的外觀與感覺。
public ref class ColumnStyle : System::Windows::Forms::TableLayoutStyle
public class ColumnStyle : System.Windows.Forms.TableLayoutStyle
type ColumnStyle = class
inherit TableLayoutStyle
Public Class ColumnStyle
Inherits TableLayoutStyle
- 繼承
範例
以下程式碼範例示範如何從 TableLayoutColumnStyleCollection中提取 a 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
備註
該 ColumnStyle 類別代表欄位的 TableLayoutPanel使用者介面(UI)特性。 此類表格中所有欄位的樣式都收集在該 TableLayoutPanel.ColumnStyles 屬性中。
這個簡單類別提供欄位的 Width 屬性 SizeType 。
建構函式
| 名稱 | Description |
|---|---|
| ColumnStyle() |
將類別的新實例 ColumnStyle 初始化為預設狀態。 |
| ColumnStyle(SizeType, Single) |
利用提供的SizeType值和寬度值初始化該ColumnStyle類別的新實例。 |
| ColumnStyle(SizeType) |
使用所SizeType提供的值初始化該類別的新實例ColumnStyle。 |
屬性
| 名稱 | Description |
|---|---|
| SizeType |
取得或設定一個旗標,指示列或欄相對於其包含資料表的大小。 (繼承來源 TableLayoutStyle) |
| Width |
取得或設定欄位的寬度值。 |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |