Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
UltraGrid - changing active appearance
posted

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.

Parents Reply
  • 2500
    Offline posted in reply to MP

    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

Children
No Data