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
530
Getting underlying value of a DropDownList
posted

I added the next ValueList to my grid, why this code doesn't return the new value of the cell?

Infragistics.Win.ValueList vl = this.myInstrumentsGrid.DisplayLayout.ValueLists.Add( "DocumentTypesValueList" );vl.ValueListItems.Add( (byte) Shared.DocumentTypeEnum.Cash, "This is cash" );vl.ValueListItems.Add( (byte) Shared.DocumentTypeEnum.Check, "This is a check" );

vl.ValueListItems.Add( (byte) Shared.DocumentTypeEnum.Deposit, "This is a deposit" );

 

WHY THE NEXT CODE DOESN'T RETURN THE NEW VALUE OF THE CELL? private void myGrid_CellChange( object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e )        {            if( e.Cell.Column.Key == "DocumentTypeEnum" )

            {

                // If before CellChage fire, the cell is Deposit and the user change it to Cash,

                // the user see in the grid "This is cash" but the underlying value 

                // is Deposit so it never enter the if. WHY?

                if( (byte) e.Cell.Value == (byte) Shared.DocumentTypeEnum.Cash )                {

                    ... code goes here ...

                }            }        }

 

Parents
  • 469350
    Verified Answer
    Offline posted

    This has nothing to do with the ValueList. The Value property of a cell returns the value from the underlying data source, so you can't use it for a cell that is currently being edited by the user. 

    This may not seem to make sense for a column with a dropdown list of values, but it's neccessary because sometimes when the user is in the middle of editing a cell in the grid the value is not valid as they are entering it. For example, suppose you have a cell in the grid that is storing dates. CellChange will fire each time the user types a key into that call. So if a user begins to enter a date and only types a single character, it is not a valid date, yet, and the Value property of the cell cannot possibly be updated at that point. 

    Anyway, what you can do is use the Text property of the cell to get the text the user has entered. To get the Value from the text, you can use cell.ValueListResolved.GetValue and pass in the text. 

    Another option might be to get the EditorResolved from the cell and examine the value of the editor. 

Reply Children
No Data