one of the columns in the Ultragrid I am working on is a Combo Box. I want to display data on the other columns when the user just selects a value from the combo box. I used the cellchanged event of the grid but I can not get the value of the combo box when the cell is changed.
Please advise what event should I have to use to get the value of the combo box when just it is selected?
Thanks
In CellChange event, you have to use cell.Text instead of cell.Value since it is the old value. You can also use AfterCellUpdate event and cell.Value will be the new value, but this event if fired only after "exit edit mode", which can be caused by moving the focus to another cell, or by code.
If you want, you can force exit edit mode when the user selects a value which make sense (I do it for checkbox also). Handle the CellChange event and write:
if (e.Cell.StyleResolved == ColumnStyle.DropDownList)
gris.PerformAction(UltraGridAction.ExitEditMode)
However, this approach won't work well with DropDown or DropDownValidate styles, since any time the user add a character, edit mode will be canceled.
You can also do it in the AfterCellListCloseUp event, but again this is not always fired for the two styles.
Thanks for your quick reply.
I changed the code to set the focus to other contol and ValueChanged event is fired. That is good.
I have one more question: when the user clears the content of the combo box, the system is throwing the following exception.
Exception = {"Cannot access the SelectedIndex property when the Editor is not in edit mode."}.
StackTrace = " at Infragistics.Win.EditorWithCombo.get_SelectedIndex()\r\n at Infragistics.Win.EditorWithCombo.ProcessTextBoxTextChanged(Boolean& selectionChangedByAutoEdit)\r\n at Infragistics.Win.EditorWithCombo.Infragistics.Win.IEmbeddableTextBoxListener.OnText...
I am using version 8.3
would you please help me in a quick. the user can clear the content of the combo box but it is throwing the above exception.
Thanks in advance for your help.
Sorry, Don't know. Can you put a small project so I can try it with my version?
We get the same error. We clear the combo box and reenter a value. It's hard to reproduce this in a small project. Below, you see the stacktrace. I worked around this problem by setting the focus to another control before the combo box processes it's value.
Do you have the latest service release? This looks like a bug that was fixed a while ago.
How to get the latest service release - Infragistics Community
That's not the latest. You should get it and see if that helps. If not, we will need a small sample project demonstrating the exception so we can get it corrected.
I tried with version 10.2.20102.2035.