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
918
Row back color
posted

I change a row back color to red in initalizerow event if a certain condition is true. I the condition changes to false I would like to change the back color to the normal color.  The problem is I use alternating row colors and have the grid back color1 and back color 2 set so a graidiant displays.  How do I get the row back to the original color?

  • 4618
    posted

    Hi morrisd,

    May I be of any further assistance regarding this issue?

    If you have any questions, at all regarding this issue or the presented solution, please let me know.

    Sincerely,
    Chris K
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com/support

     

  • 4618
    posted

    Hi morrisd,

    After further contemplation and a bit of guidance, I have determined a solution which I believe mirrors your intended goal exactly. I have attached a modified version of my earlier sample which relies entirely on the InitializeRow event as you described in your original post for checking values in each row. This sample will update the row color, if the condition is satisfied, not only when the Grid is initialized, but also if the value is changed at a later time.

    Please let me know if you have any questions at all regarding this issue or the solution that I have presented.

    Sincerely,
    Chris K
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com/support

     

    GridRowColorGradient Sample.zip
  • 4618
    posted

    Hi morrisd,

    I have attached a sample, demonstrating how you might make use of the AfterRowUpdate event for achieving the effect you are describing. Note that this might also be used in conjunction with whatever conditional you are setting during initialization of the row; in this way when the row is initialized and the statement is satisfied, the row would update its color, but would also revert back to its original color if the condition is no longer met at a later time in your application.

    This sample is based in the context of cell value to satisfy a particular condition, in this case if the first cell in any of the rows has a value of “0”, then the row color will change to red and if any other value is present in the cell it will revert back to its original color. I have also implemented Mike’s suggestion on setting e.Row.Appearance = null; while slightly different from what I was initially going to suggest, it is a much more elegant approach.

    If you have any question at all, regarding the attached sample or the solution, please let us know.

    Sincerely,
    Chris K
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com/support

     

    GridRowColorGradient Sample.zip
  • 469350
    Offline posted

    To return the row to it's original appearance, just set:

    e.Row.Appearance = null

  • 4618
    posted

    Hi morrisd,

    I am going to look into this issue further and put together a sample for this issue. It looks like, from your description, you are only setting the row color when initializeRow is called, however this does not, (normally) occur regularly enough to qualify as real-time; and at times may even appear as if the row color is never updating at all. I would suggest setting the row color during an event that occurs more often, for example, maybe by taking advantage of the Before and After cell update events. I will construct a sample for this issue and I will post in in my next response.

    If you have any questions at all regarding this issue please let me know.

    Sincerely,
    Chris K
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com/support