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
695
Question about incosistency value at UltraGrid.AfterCellUpdate(e.cell.originalvalue)
posted

Hi,

I assign a ValueList to a cell: -

Infragistics.Win.ValueList vl;

vl = grid.DisplayLayout.ValueLists.Add("TestValueList");

vl.ValueListItems.Add(1, "A");

vl.ValueListItems.Add(2, "B");

grid.DisplayLayout.Bands[0].Columns[2].ValueList = grid.DisplayLayout.ValueLists["TestValueList"];

Then at UltraGrid.AfterCellUpdate(): -

private void grid_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)

{ …

                grid.EventManager.SetEnabled(Infragistics.Win.UltraWinGrid.GridEventIds.A      fterCellUpdate, false);

 

                                if (e.Cell.OriginalValue.ToString() == "A")

                                { e.Cell.Value = 1; }

                                else

                                { e.Cell.Value = 2; }

                                grid.EventManager.SetEnabled(Infragistics.Win.UltraWinGrid.GridEventIds.A      fterCellUpdate, true);

 

 }

 

However, I couldn’t get a consistent value back at the e.Cell.OriginalValue: -

Original value selected is A

Test attempt

Value

Text

OriginalValue

Select “B” in the list

2

B

A

Select “A” in the list

1

A

2

 Why the OriginalValue sometimes return me Text of the value list and sometimes is the selected index?

How can i restored the original value?

Thanks

Parents
No Data
Reply
  • 69832
    Offline posted

    I don't think setting the cell's Value property in response to AfterCellUpdate is a good idea, because at that point it is in the process of committing the last value it had. In any case, the reason that sometimes the text is returned and sometimes the value is returned is because our ValueList behaves like a ComboBox control insofar as, when there is no selected item, the text typed by the user is returned as the value.

    The cell's original value is maintained during the course of an edit mode session, so that if the user presses escape (synonymous with canceling the BeforeExitEditMode event), the cell's value is reverted. At the time AfterCellUpdate fires, on the other hand, it has already been committed and the "original" value is lost.

    It would seem possible that you are mistaken about the expected function of the AfterCellUpdate event, and you should be using BeforeExitEditMode instead.

Children