Hi.
I am able to change the active appearance back color of a cell using the following line of code:
cell.ActiveAppearance.BackColor = Color.Yellow;
Is there a way to set this at the row level? I don't see a row.ActiveAppearance object.
Thanks.
Hi Mahadevan,
Thank you for clarifying.
According to the ActiveRowAppearance Property API, the lowest level the property can be set on is the UltraGrid Band. Meaning, even with the suggested approach from the previously referenced topic about changing the appearance of the grid rows that involves handling the InitializeRow event of the grid and setting appearances on individual rows there, would not help here. The design assumes that the active row style would be identical on a grid/band level, as the “active” indication is expected to be uniform among the rows. Presumably this would be most straightforward and least confusing to the user.
Nevertheless, if different active back colors for different rows is indeed your target, a workaround approach I can suggest is handling the BeforeRowActivate event of the grid and setting the ActiveRowAppearance property for the Band the row belongs to. For example:
private void ultraGrid1_BeforeRowActivate(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { if (e.Row.Band.Index == 0 && e.Row.Cells["Column 0"].Value.ToString() == "1") { e.Row.Band.Override.ActiveRowAppearance.BackColor = Color.LightSalmon; } else if (e.Row.Band.Index == 0 && e.Row.Cells["Column 0"].Value.ToString() == "2") { e.Row.Band.Override.ActiveRowAppearance.BackColor = Color.LightGray; } }
Attached you will find a minimal sample demonstrating this approach. Please, check it out and if you require any further assistance on the matter, please, let me know.
Best regards, Bozhidara Pachilova Associate Software Developer
1682.UGActiveRowAppearances.zip
Hi Bozhidara.
Thank you for your reply. I am not sure if that's quite what I am looking for.
The grid.DisplayLayout.Override.ActiveRowAppearance property applies to the entire grid. Whichever row is the active row of the grid, that row would display what is set in the ActiveRowAppearance.
What I am looking for is to set the ActiveAppearance property differently for different rows. As an example, suppose I want:
How do I set the ActiveAppearance property for each row?
One way would be to loop through the cells in each row and set this at the cell level. But that's cumbersome. Can this be set at the row level?
Thank you for posting to Infragistics Community!
Sure, the UltraGrid’s DisplayLayout.Override object exposes the ActiveRowAppearance Property:
this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.BackColor = Color.Yellow; this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.ForeColor = Color.Red;
More about creating and applying appearances can be found in this topic in our documentation and about Changing the Appearance of WinGrid Rows - in this one.
Should you need further assistance on the matter, we will be glad to assist you.