DataGrid.ResetAlternatingBackColor 方法

定义

AlternatingBackColor 属性重置为其默认颜色。

public:
 void ResetAlternatingBackColor();
public void ResetAlternatingBackColor ();
member this.ResetAlternatingBackColor : unit -> unit
Public Sub ResetAlternatingBackColor ()

示例

下面的代码示例演示了此成员的用法。

// String variable used to show message.
String^ myString = "Selection backgound color changed from: ";

// Store current foreground color of selected cells.
Color myCurrentColor = myDataGrid->SelectionBackColor;
myString = String::Concat( myString, myCurrentColor.ToString() );

// Reset selection background color to default.
myDataGrid->ResetSelectionBackColor();
myString = String::Concat( myString, " to " );
myString = String::Concat( myString, myDataGrid->SelectionBackColor.ToString() );

// Show information about changes in color setting.  
MessageBox::Show( myString, "Selection background color information" );
// String variable used to show message.
string myString = "Selection backgound color changed from: ";
// Store current foreground color of selected cells.
Color myCurrentColor = myDataGrid.SelectionBackColor;
myString += myCurrentColor.ToString();
// Reset selection background color to default.
myDataGrid.ResetSelectionBackColor();
myString += "  to ";
myString += myDataGrid.SelectionBackColor.ToString();
// Show information about changes in color setting.  
MessageBox.Show(myString, "Selection background color information");
' String variable used to show message.
Dim myString As String = "Selection backgound color changed from: "
' Store current foreground color of selected cells.
Dim myCurrentColor As Color = myDataGrid.SelectionBackColor
myString += myCurrentColor.ToString()
' Reset selection background color to default.
myDataGrid.ResetSelectionBackColor()
myString += "  to "
myString += myDataGrid.SelectionBackColor.ToString()
' Show information about changes in color setting.  
MessageBox.Show(myString, "Selection background color information")

注解

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

适用于

另请参阅