Hi,
I have found an example how to assign a Tag value to a new ValueListItem.
ValueListItem valueListItem = shippersValueList.ValueListItems.Add( shipperID, shipperName );
valueListItem.Tag = dataRow;
How can I access Tag value from CellChange event?
Thank you
CellChange could be a bit tricky, because (depending on the Style of the column), the user could type something in the cell that is not on the list.
In any case, you will need to get the currently selected item based on the current cell text and then get the tag from that item. Here's some quick sample code:
private void ultraGrid1_CellChange(object sender, CellEventArgs e) { UltraGrid grid = (UltraGrid)sender; UltraGridCell activeCell = grid.ActiveCell; ValueList valueList = (ValueList)activeCell.ValueListResolved; if (valueList != null) { int selectedIndex = -1; object value = ((IValueList)valueList).GetValue(activeCell.Text, ref selectedIndex); if (selectedIndex >= 0 && selectedIndex < valueList.ValueListItems.Count) { ValueListItem selectedItem = valueList.ValueListItems[selectedIndex]; Debug.WriteLine(selectedItem.Tag); } } }
Thank you , it worked