DataGrid.ResetHeaderForeColor 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
重設 HeaderForeColor 屬性為其預設值。
public:
void ResetHeaderForeColor();
public void ResetHeaderForeColor ();
member this.ResetHeaderForeColor : unit -> unit
Public Sub ResetHeaderForeColor ()
範例
下列程式碼範例示範此成員的使用。
private:
void button3_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->HeaderForeColor;
// Show color dialog box.
myColorDialog->ShowDialog();
// Set the header foreground color.
myDataGrid->HeaderForeColor = myColorDialog->Color;
}
// Reset the header foregroundcolor.
void button4_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myDataGrid->ResetHeaderForeColor();
}
private void button3_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.HeaderForeColor;
// Show color dialog box.
myColorDialog.ShowDialog();
// Set the header foreground color.
myDataGrid.HeaderForeColor = myColorDialog.Color;
}
// Reset the header foregroundcolor.
private void button4_Click(object sender, EventArgs e)
{
myDataGrid.ResetHeaderForeColor();
}
Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button3.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.HeaderForeColor
' Show color dialog box.
myColorDialog.ShowDialog()
' Set the header foreground color.
myDataGrid.HeaderForeColor = myColorDialog.Color
End Sub
' Reset the header foregroundcolor.
Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button4.Click
myDataGrid.ResetHeaderForeColor()
End Sub
備註
如果您要為 System.Windows.Forms.DataGrid 建立 設計工具,或建立自己的控制項併入 System.Windows.Forms.DataGrid ,您通常會使用這個方法。 您可以使用 ShouldSerializeHeaderForeColor 方法來判斷屬性值是否已從預設值變更。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應