DataGridView.EnableHeadersVisualStyles 屬性

定義

取得或設定值,指出已針對應用程式啟用視覺化樣式時,資料列和資料行行首是否使用使用者的目前佈景主題的視覺化樣式。Gets or sets a value indicating whether row and column headers use the visual styles of the user's current theme if visual styles are enabled for the application.

public:
 property bool EnableHeadersVisualStyles { bool get(); void set(bool value); };
public bool EnableHeadersVisualStyles { get; set; }
member this.EnableHeadersVisualStyles : bool with get, set
Public Property EnableHeadersVisualStyles As Boolean

屬性值

Boolean

如果已為標頭啟用視覺化樣式,則為true ;否則為 falsetrue if visual styles are enabled for the headers; otherwise, false. 預設值是 trueThe default value is true.

範例

下列程式碼範例示範如何在啟用視覺化樣式的應用程式中,停用資料列和資料行標頭的視覺化樣式。The following code example demonstrates how to disable visual styles for the row and column headers in an application that has visual styles enabled. 在此範例中,會藉由呼叫中的方法,為應用程式啟用視覺化樣式 EnableVisualStyles MainIn this example, visual styles have been enabled for the application by calling the EnableVisualStyles method in Main. 不過,視覺效果樣式不會套用至資料列和資料行標頭,因為 EnableHeadersVisualStyles 會設定為 falseHowever, visual styles will not be applied to the row and column headers because EnableHeadersVisualStyles is set to false. 這個程式碼範例是針對類別提供之較大範例的一部分 DataGridViewAdvancedBorderStyleThis code example is part of a larger example provided for the DataGridViewAdvancedBorderStyle class.

public CustomDataGridView()
{
    this.RowTemplate = new DataGridViewCustomRow();
    this.Columns.Add(new DataGridViewCustomColumn());
    this.Columns.Add(new DataGridViewCustomColumn());
    this.Columns.Add(new DataGridViewCustomColumn());
    this.RowCount = 4;
    this.EnableHeadersVisualStyles = false;
    this.AutoSize = true;
}
Public Sub New()
    With Me
        .RowTemplate = New DataGridViewCustomRow()
        .Columns.Add(New DataGridViewCustomColumn())
        .Columns.Add(New DataGridViewCustomColumn())
        .Columns.Add(New DataGridViewCustomColumn())
        .RowCount = 4
        .EnableHeadersVisualStyles = False
        .AutoSize = True
    End With
End Sub

備註

您可以藉由在呼叫方法之前呼叫方法來啟用應用程式的視覺化樣式 Application.EnableVisualStyles Application.RunYou can enable visual styles for your application by calling the Application.EnableVisualStyles method before calling the Application.Run method. 如果 EnableHeadersVisualStyles 設定為 true ,則所有標頭資料格(除了) TopLeftHeaderCell 都會使用目前的主題來繪製。If EnableHeadersVisualStyles is set to true, all header cells except the TopLeftHeaderCell are painted using the current theme.

適用於

另請參閱