Share via


DataGrid.ResetHeaderBackColor 方法

HeaderBackColor 属性重置为其默认值。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Sub ResetHeaderBackColor
用法
Dim instance As DataGrid

instance.ResetHeaderBackColor
public void ResetHeaderBackColor ()
public:
void ResetHeaderBackColor ()
public void ResetHeaderBackColor ()
public function ResetHeaderBackColor ()

备注

如果要创建 System.Windows.Forms.DataGrid 的设计器或创建您自己的、包含 System.Windows.Forms.DataGrid 的控件,则通常使用此方法。可使用 ShouldSerializeHeaderBackColor 方法确定属性值是否已更改,不再是默认值。

示例

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 'button1_Click

' Reset the header background color.
Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button2.Click
    myDataGrid.ResetHeaderBackColor()
End Sub 'button2_Click
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:
   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.set_AllowFullOpen(false);
    
    // Enable the help button.
    myColorDialog.set_ShowHelp(true);
    
    // Set the initial color to the current color.
    myColorDialog.set_Color(myDataGrid.get_HeaderBackColor());
    
    // Show color dialog box.
    myColorDialog.ShowDialog();
    
    // Set the header background color.   
    myDataGrid.set_HeaderBackColor(myColorDialog.get_Color());
} //button1_Click

// Reset the header background color.
private void button2_Click(Object sender, EventArgs e)
{
    myDataGrid.ResetHeaderBackColor();
} //button2_Click

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

DataGrid 类
DataGrid 成员
System.Windows.Forms 命名空间