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?
I am just checking about the progress of this issue. Let me know if you need my further assistance on it.
Thank you for using Infragistics Components.
Yes, it appears that this event, AfterCellListCloseUp, does not fire if the user selects an item in the DropDown cell containting a ValueList via the keyboard, but it does when the mouse is used to select a ValueListItem.
What can I do to make it fire via the keyboard?
Thank you for your feedback.
AfterCellListCloseUp event occurs after a cell’s combo has been closed. This is the case when the user clicks with the mouse in the combo or if she navigate to the cell via the keyboard, clicks shift + down arrow and select value. More about AfterCellListCloseUp event you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2015.1/CLR4.0/html/Infragistics4.Win.UltraWinGrid.v15.1~Infragistics.Win.UltraWinGrid.UltraGrid~AfterCellListCloseUp_EV.html Please note when after the combo has been closed only the text of the cell is changed. The value of the cell changes after the cell exits edit mode. This is why I am calling PerformAction method and force the cell to exit edit mode.
However if the user navigates with the keyboard and never drop down the cell’s combo this event will not fire. This is where you may use AfterCellUpdate event. When the user navigates with the keyboard, without dropping down the combo both value and text of the cell are changing.
Please try to explain what you are trying to achieve in your scenario and I will be happy to investigate this further for you.
The users of this software want to enter data in the grid without using the mouse. They are "power users". For them to have to use the mouse to ensure that the combo/grid is operating "correctly" slows them down.
The combo is the first column in the grid. After selecting the desired row within the combo, I need to check that the selected value does not exist in any other row within the grid. If it does, I need to tell the user and not allow the row to be created with this value.
Further, the last row is a decimal datatype. I use the selected value of the combo box to lookup the most current unit cost paid for this item in table other than the primary one on which this grid is based.
Thanks for your help.
We are still following this forum thread.
Please feel free to let us know if you still have any questions on this matter.
The value of the cell does not change before the cell exits edit mode. While the user selects values from the combo, with the mouse or via the keyboard, only the text of the cell is changing.
In order to get the possible value the user tries to set, before the cell exits edit mode, you may parse the text of the cell through the value list to a possible value of the cell. To be able to handle most scenarios you may use CellChange event. In this event you can take the current text of the cell and try to get the related value in your value list. More about this event you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2015.1/CLR4.0/html/Infragistics4.Win.UltraWinGrid.v15.1~Infragistics.Win.UltraWinGrid.UltraGrid~CellChange_EV.html
Please note in this scenario if the user is allowed to enter a value that does not exist in the value list you need to handle this and return some default or null value.
Please check the attached sample project implementing this approach and let me know if you need any further assistance on this.