Hi
I have a grid bound to a dataset. In one of the colulms i have a code field and and a value list associated with it. When the user selects a value from the dropdown i want to check the underlying code to see if it matches a certain criteria.
I am currently trapping the CellListSelect event as below.
private void ultraGrid1_CellListSelect(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { // CellListSelect gets fired when an item from a drop down is selected when editing // a cell. Cell would have to be in edit mode for this to get fired. Following code // prints out the selected item idex for value list drop downs. if ( null != e.Cell.Column.ValueList ) { int itemIdex = e.Cell.Column.ValueList.SelectedItemIndex; Debug.WriteLine( "Selected Item Index = " + itemIdex ); } }
The probem is that the valuelist always seems to be null. So how do i check the underlying code of the item that was selected?
I found it.
string selectedCode = e.Cell.ValueListResolved.GetValue(e.Cell.ValueListResolved.SelectedItemIndex).ToString();
I think you could also just use e.Cell.Value
I also had to use e.Cell.ValueListResolved.GetValue(e.Cell.ValueListResolved.SelectedItemIndex) to get to the value.
It appears that the e.Cell.Value gets set much later in the sequence of events than the e.Cell.Text. l didn't test all events but from what I've seen simply selecting a value from the value list without leaving the cell and checking the contents of e.cell When the AfterCellUpdate, CellChange, CellListSelect and AfterCellListCloseUp events fire produces the correct e.cell.text but returns a system.db.null for the e.cell.value. If I leave the cell for another cell then I do indeed have both a e.cell.text and an e.cell.value.
By using the e.Cell.ValueListResolved.GetValue(e.Cell.ValueListResolved.SelectedItemIndex) in the previously listed events I get what the e.cell.value should return. (Or at least it lets you get it sooner)
Cam