Within a WinForms UlraGrid, I am looking for a means (via code) to alter the appearance of an entire row, whenever a targeted column value meets a certain condition. For example, I already know that I can target the respect cell via the ConditionValueAppearance. The closest I could find to what might work is the ConditionAppearanceRow Class. Unfortunately you don't provide any code snippets to demonstrate how this class is hooked up with a given DisplayLayout Band.
In any case, I need this capability through code, so I can set the row appearance on the fly. If there is another way to do this, I am all ears.
Conditional Appearances are really useful for setting things up at Design-time. But at run-time, they actually require more code than neccessary and it's much easier to do things a different way.
I recommend using the InitializeRow event of the grid. This event is specifically designed to help you with situations just like this one where you want to color the row based on a value inside that row. All you do is handle the event, examine the row and it's cells and then set the Appearance properties on the row to suit your needs.
Happy New Year and thanks for the reply. I'll give the above mentioned approach a shot.
I have a follow-up question. The InitializeRow event fires when a row is first added, or when the data for the row is refreshed explicity. In my case, I need to set the appearance of the whole row when the data is updated as a result of the values in underlying BindingList changing (these values change as a result of events external to the UI - so I cannot capture any user data entry events).
E.g., if the 'status' field of an object in the BindingList changes from 'OK' to 'Warning' then the entire row should be displayed in red.
What is the recommended way to address this scenario using the UltraGrid?
Assuming that your data source is an IBindingList and notifies the grid that the field value has change, then the grid will update the display of the row automatically and fire InitializeRow. So you would do this the same way.
If your data source is an IList, then the grid will not be notified. So you can manually trigger the InitializeRow using the grid.Rows.Refresh method - just be sure to pass in FireInitializeRow.
Thanks Mike. I figured out that my problem was that when raising the PropertyChanged event of the object in the BindingList, I didn't supply a property name (because multiple properties changed at the same time). I changed my code to supply an arbitrary property name and the InitializeRow event started to fire on updates. Don't know if this is a UltraGrid or a BindingList requirement, but it works now.