NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataGrid.AlternatingBackColor

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);

Property Value

A Color that represents the alternating background color. The default is the background color of the control.

Remarks

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.

Example [Visual Basic]

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

See Also

DataGrid Class | DataGrid Members | System.WinForms Namespace