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
170
Issue with OriginalValue Property
posted

Hello,

I am using a ultrawingrid control and am trying to  change the cell color whenever a user changes a cell in the grid. I am using the following code. This works fine for everything except in one case. When the originalvalue is null and user enters a new value. In this case, both the original value and the value property are shown the same (i.e the new value entered). So the color doesn't change (based on my logic below).

 void objGrid_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
        {
          
            bool valChanged = false;
          

            if (e.Cell.Value == null && e.Cell.OriginalValue == null)
            {
                valChanged = false;
            }
            else if (e.Cell.Value == null && e.Cell.OriginalValue != null)
            {
                valChanged = true;
            }
            else if (e.Cell.Value != null && e.Cell.OriginalValue == null)
            {
                valChanged = true;
            }

            else if (e.Cell.Value.ToString() != e.Cell.OriginalValue.ToString())
            {
                valChanged = true;               
            }
            if (valChanged)
            {
                e.Cell.Appearance.BackColor = Color.BlanchedAlmond;
                e.Cell.Row.RowSelectorAppearance.BackColor = Color.BlanchedAlmond;
            }

        



        }