Gets or sets the background color of alternating rows for a ledger appearance.
[Visual Basic] Public Property AlternatingBackColor As Color [C#] public Color AlternatingBackColor {get; set;} [C++] public: __property Color get_AlternatingBackColor(); public: __property void set_AlternatingBackColor(Color); [JScript] public function get AlternatingBackColor() : Color; public function set AlternatingBackColor(Color);
A Color that represents the alternating background color. The default is the background color of the control.
By default, all rows have the same color (the BackColor property of the control). When you set the AlternatingBackColor to a new color, every other row is set to the new color.
To reset the alterating background color to its default value, set the property to Color.Empty.
The following example sets the alternating background color using a Color passed as an argument to the method.
[Visual Basic]
Private Sub ToggleAltBackClr(ByVal myGrid As DataGrid, ByVal c As System.Drawing.Color) Static isAlternating As Boolean If isAlternating Then myGrid.AlternatingBackColor = Nothing isAlternating = False Else myGrid.AlternatingBackColor = c isAlternating = True End If End Sub ' To call the method: Private Sub CallMethod() Dim c As Color c = New System.Drawing.Color.Red ToggleAltBackClr DataGrid1, c End Sub
DataGrid Class | DataGrid Members | System.WinForms Namespace