DataGrid.ResetHeaderBackColor 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
重設 HeaderBackColor 屬性為其預設值。
public:
void ResetHeaderBackColor();
public void ResetHeaderBackColor ();
member this.ResetHeaderBackColor : unit -> unit
Public Sub ResetHeaderBackColor ()
範例
下列程式碼範例示範如何使用這個成員。
private:
void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
ColorDialog^ myColorDialog = gcnew ColorDialog;
// Disable selecting a custom color.
myColorDialog->AllowFullOpen = false;
// Enable the help button.
myColorDialog->ShowHelp = true;
// Set the initial color to the current color.
myColorDialog->Color = myDataGrid->HeaderBackColor;
// Show color dialog box.
myColorDialog->ShowDialog();
// Set the header background color.
myDataGrid->HeaderBackColor = myColorDialog->Color;
}
// Reset the header background color.
void button2_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myDataGrid->ResetHeaderBackColor();
}
private void button1_Click(object sender, EventArgs e)
{
ColorDialog myColorDialog = new ColorDialog();
// Disable selecting a custom color.
myColorDialog.AllowFullOpen = false ;
// Enable the help button.
myColorDialog.ShowHelp = true ;
// Set the initial color to the current color.
myColorDialog.Color = myDataGrid.HeaderBackColor;
// Show color dialog box.
myColorDialog.ShowDialog();
// Set the header background color.
myDataGrid.HeaderBackColor = myColorDialog.Color;
}
// Reset the header background color.
private void button2_Click(object sender, EventArgs e)
{
myDataGrid.ResetHeaderBackColor();
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
Dim myColorDialog As New ColorDialog()
' Disable selecting a custom color.
myColorDialog.AllowFullOpen = False
' Enable the help button.
myColorDialog.ShowHelp = True
' Set the initial color to the current color.
myColorDialog.Color = myDataGrid.HeaderBackColor
' Show color dialog box.
myColorDialog.ShowDialog()
' Set the header background color.
myDataGrid.HeaderBackColor = myColorDialog.Color
End Sub
' Reset the header background color.
Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button2.Click
myDataGrid.ResetHeaderBackColor()
End Sub
備註
如果您要為 建立設計工具 System.Windows.Forms.DataGrid ,或建立自己的控制項並 System.Windows.Forms.DataGrid 入 ,您通常會使用這個方法。 您可以使用 ShouldSerializeHeaderBackColor 方法來判斷屬性值是否已從預設值變更。