Two properties of an object displayed in the Ultragrid are PartId and PartDescription.
One column in the UltraGrid is a dropdown containing a ValueList. It is composed of a collection of ValueListItems (dataValue(PartId) and displayText(PartDescription).
I attached the ValueList to the PartDescription column in the grid. The PartId column is hidden.
After making a selection from the dropdown at run-time, the underlying object has the PartDescription set to the dataValue of the ValueListItem. The PartId is null.
How can I correct this, so the DataValue property is assigned to PartId and the DisplayText property is assigned to PartDescription?
Hello Lars,
Thank you for posting in our forum.
If I understand you correctly you have a grid with two columns, PartId and PartDescription. You need to show the PartDescription of a particular object and when the user choose an object by PartDescription you need to retrieve the PartId of the chosen object. If this is your scenario you are on the right way with using ValueList. ValueList contains ValueListItems, which you need to populate in run time. Each ValueListItem has a DataValue and DisplayText. This way ValueList can translate ids into user-friendly text. What you need to do is to create only one column in your grid – Part Description column and assign your value list to this column. More about best practices for setting up a drop down in UltraGrid cell you may find by following the next link http://blogs.infragistics.com/winforms/wiki/best-practices-for-placing-a-dropdown-or-combo-in-an-wingrid-cell/2.aspx
Please check the attached sample solution implementing UltraGrid with ValueList and let me know if this is what you are looking for or if I am missing something.
Thanks for the help, Milko. It was especially helpful to see how you assigned both properties from the cell's Value and Text properties in your sample code.
However, if the user selects an item from the dropdown via keyboard control, not the mouse, I don't believe this event is triggered. In this case, the two properties do not get updated.
Is there any way around this?