HI,
I set up an Ultragrid with alternate row color by running following codes after the grid was populated with data:
For x = 0 To anICDs.GetUpperBound(0)
For y = 0 To Me.Rows.Count - 1
If CInt(Me.Rows(y).Cells("Position").Value) - 1 = anICDs(x) Then
Me.Rows(y).Appearance.BackColor = CType(IIf(x Mod 2 = 0, Color.White, Color.GreenYellow), Color)
End If
Next
I works during display time. But when I insert a blank row into the grid, the backcolor is still the default gray (see row 3,4), I would like the blank row to have the same GreenYellow color. Is there a grid property I can set to accomplish this? Or is there an event I can duplicate the above code in?
Thank you.
You should set RowAlternateAppearance of the grid's override. You can use code like this
this.ultraGrid1.DisplayLayout.Override.RowAlternateAppearance.BackColor = Color.Red;
You can also set alternate row appearance via the grid designer. To do so open the designer dialog. Navigate to Basic Settings -> Appearance Browser. Then under Appearance Browser section select Row Appearance -> Row Alternate. Then you can set whatever property you need in the properties panel.
More information about row alternate appearance you can find in the online documentation in this article "Setting Alternate Row Colors"
How do you do this can you explain is that design time Property?
Hi,
I would definitely recommend using the RowAlternateAppearance rather than trying to set the Appearance on each row yourself. Doing it manually will be very difficult - you will have to constantly update the row appearances every time something changes. Why not let the grid do it for you?
I don't see any good way to do this. You could try to keep track of whether the addnew row is odd or even and then set the appropriate appearance (TemplateAddRowAppearace, AddRowAppearance).
I also tried this command but did not seem to work:
Me.DisplayLayout.Bands(0).Override.RowAlternateAppearance.BackColor = Color.Red
BTW, I am using Version 9.1.