Alternate row color in datagrid

jccorner

Centurion
Joined
Jan 31, 2004
Messages
144
Simple question. How do I change the alternate row color in a datagrid?? I've tried the alternating row color in the designer, but that doesn't seem to work. The only way I can get it to work is if I use the datagrid properties expert and use a defined template.

Also, does anyone know how to get the report viewer to maximize?? I want it to maximize regardless the screen settings on the pc. Thanks.
 
Perhaps you should create a class that inherits DataGridTextBoxColumn class, and add this functionality to the new class, changing the backcolor property for its textbox hosted control. It must have an easier solution, but I don't know.
 
m_oliveira said:
Perhaps you should create a class that inherits DataGridTextBoxColumn class, and add this functionality to the new class, changing the backcolor property for its textbox hosted control. It must have an easier solution, but I don't know.

It is probably easier to add a DataGridTableStyle to the datagrid similar to the following.

Public Sub AddCustomDataTableStyle(ByRef dgrid As DataGrid, ByVal p_tablename As String)

' Create a new DataGridTableStyle and set
' its MappingName to the TableName of a DataTable.
Dim ts1 As New DataGridTableStyle()

dgrid.TableStyles.Clear()

'----------------------------------------------------

ts1.MappingName = p_tablename '"Psuedo_Habitat"

ts1.AlternatingBackColor = System.Drawing.Color.LightYellow ' System.Drawing.Color.Gainsboro
ts1.BackColor = System.Drawing.Color.Ivory ' System.Drawing.Color.WhiteSmoke
ts1.GridLineColor = System.Drawing.Color.SlateGray

'----------------------------------------------------
dgrid.TableStyles.Add(ts1)

End Sub
 
Back
Top