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
395
ValueBasedAppearance for Grid Rows
posted

I use the function ValueBasedAppearance and find this very well done.

Is there a way this function on rows in the grid to be applied.

e.g.
Row.ValueBasedAppearance = .....

I would like to set some appearance to a row based on a value in a cell, without using any loops.

 

 

THX

  • 37774
    Verified Answer
    posted

    In your case your best option would be to use the InitializeRow event, checking individual cells and assigning appearances accordingly.  The ValueBasedAppearance can essentially be thought of as a design-time mechanism for wrapping what you can do in the InitializeRow event.  If you're going to be using the same Appearance object repeatedly, you might consider re-using the same object for efficiency as well:

    private Infragistics.Win.Appearance redAppearance;
    private Infragistics.Win.Appearance RedAppearance
    {
        get
        {
            if (this.redAppearance == null)
            {
                this.redAppearance = new Infragistics.Win.Appearance();
                this.redAppearance.BackColor = Color.Red;
            }
            return this.redAppearance;
        }
    }

    private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
    {
        if ((int)e.Row.Cells["Col 2"].Value == 3)
            e.Row.Appearance = this.RedAppearance;
        else
            e.Row.Appearance = null;
    }

    -Matt