I have created a InitializeRow method below. I use it to style rows in a grid based on the strings contained within the selected row. This works fine but the style is not applied if the row is highlighted, ibstead the original isl style is applied. Basically what i want to know is can i apply a style like "Me.gridTillItems.DisplayLayout.Override.ActiveRowAppearance = VoidStyle" but just to the selected row using the InitializeRowEventArgs object
Private Sub gridTillItems_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles gridTillItems.InitializeRow
If e.Row.Cells("ItemName").Value.ToString.ToUpper.Contains("VOID") Then
Dim VoidStyle As Infragistics.Win.Appearance = New Infragistics.Win.Appearance With VoidStyle .ForeColor = Color.Black .FontData.SizeInPoints = 10 .FontData.Strikeout = DefaultableBoolean.True End With e.Row.Appearance = VoidStyle
End If
End Sub
If I understood this correctly, it sounds like you want to assign an appearance to certain rows that takes effect only when they are activated. Since you mentioned the row being "highlighted", I am assuming that by selected you mean it exhibits the SelectedAppearance, and its Selected property returns true.
The UltraGridRow class exposes an Appeareace (as you know), but this is a stateless appearance, and state-specific appearances override it when the row is in that state. To work around this for your purposes, I think you might be able to do something like handle the BeforeSelectChange or AfterSelectChange events, and set the row's Appearance property differently based on whatever criteria you are using.
Thanks for the quick response. You are quite right that is exactly what i am trying to achieve. I have had a quick play with the handlers you surgested but as I havent used them before I am a bit stuck. If you could point a lost developer in the righ direction I would be most gratefull.
I don't think those events will help in this case, because the WinGrid resolves the selected colors of the rows by default. There's no way to turn this off and the selected color will override the row color. This issue is discussed in detail, along with a possible solution using a DrawFilter here: DrawFilter for Backcolor - Infragistics Forums
In this case, though, there is probably an easier way. In addition to setting the row.Appearance, you can also set the SelectedAppearance on each cell in the row to the same appearance.