Share via


DataGrid.BackgroundColor 属性

获取或设置网格中非行区域的颜色。

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

语法

声明
Public Property BackgroundColor As Color
用法
Dim instance As DataGrid
Dim value As Color

value = instance.BackgroundColor

instance.BackgroundColor = value
public Color BackgroundColor { get; set; }
public:
property Color BackgroundColor {
    Color get ();
    void set (Color value);
}
/** @property */
public Color get_BackgroundColor ()

/** @property */
public void set_BackgroundColor (Color value)
public function get BackgroundColor () : Color

public function set BackgroundColor (value : Color)

属性值

一个 Color,它代表网格的背景的颜色。默认是 AppWorkspace 颜色。

备注

BackgroundColor 确定网格中非行区域的颜色,该颜色仅在 System.Windows.Forms.DataGrid 未显示任何表、网格滚动到底部或网格中只包含几行时可见。

示例

下面的代码示例设置 BackColorBackgroundColor 属性。

Private Sub SetGridColors()
    dataGrid1.BackColor = System.Drawing.Color.Red
    dataGrid1.AlternatingBackColor = System.Drawing.Color.AliceBlue
    dataGrid1.BackgroundColor = System.Drawing.Color.Yellow
End Sub 'SetGridColors
private void SetGridColors(){
    dataGrid1.BackColor=System.Drawing.Color.Red;
    dataGrid1.AlternatingBackColor= System.Drawing.Color.AliceBlue;
    dataGrid1.BackgroundColor=System.Drawing.Color.Yellow;
 }
 
private:
   void SetGridColors()
   {
      dataGrid1->BackColor = System::Drawing::Color::Red;
      dataGrid1->AlternatingBackColor = System::Drawing::Color::AliceBlue;
      dataGrid1->BackgroundColor = System::Drawing::Color::Yellow;
   }
private void SetGridColors()
{
    dataGrid1.set_BackColor(System.Drawing.Color.get_Red());
    dataGrid1.set_AlternatingBackColor(
        System.Drawing.Color.get_AliceBlue());
    dataGrid1.set_BackgroundColor(System.Drawing.Color.get_Yellow());
} //SetGridColors

平台

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

.NET Compact Framework

受以下版本支持:2.0

请参见

参考

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