I have a value list in my UltraWinGrid. When user drops down value list using F4 key and then presses ENTER key without selecting anything in list, it causes NullReferenceException. The stack trace is given below:
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Win.EditorWithCombo.Infragistics.Win.IValueListOwner.OnSelectionChangeCommitted() at Infragistics.Win.EditorWithCombo.InternalOnEmbeddableTextBoxListenerKeyDown(KeyEventArgs e) at Infragistics.Win.EditorWithCombo.Infragistics.Win.IEmbeddableTextBoxListener.OnKeyDown(KeyEventArgs e) at Infragistics.Win.EditorWithCombo.OnOwnerKeyDown(KeyEventArgs e) at Infragistics.Win.EmbeddableEditorBase.ProcessOwnerKeyDown(Object sender, KeyEventArgs e) at Infragistics.Win.EmbeddableEditorOwnerBase.RaiseKeyDown(KeyEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.ForwardKeyToEditorHelper(KeyEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGridUIElement.ProcessKeyDown(KeyEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraControlBase.OnKeyDown(KeyEventArgs e) at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m) at System.Windows.Forms.Control.WmKeyChar(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
What version of the controls are you using? Do you have the latest service release?
How to get the latest service release - Infragistics Community
Thanks Mike,
I have version 10.2.20102.1004 for Infragistics2.Win.UltraWinGrid.v10.2 the other controls are also from same release.
If I can get the event where it is checked if there is any value selected by user or not that will be easier as getting updated release is bit lengthy (bureaucracy!)
There is no event you can handle and therefore no way to work around this... unless maybe you try to catch and handle the KeyDown/KeyUp events of the grid before it gets to the editor. I haven't tried that, though, so I don't know if it's possible.
Hi Mike, thanks for your suggestion. I think I have cracked it. The setup is as follows:
Handle AfterCellListCloseUp, BeforeCellListDropDown, and PreviewKeyDown events for the Grid. Define a boolean variable, mine is _dropdownShowing.
Now code handlers for events:
void Grid_BeforeCellListDropDown(object sender, CancelableCellEventArgs e) { _dropdownShowing = true; }
void Grid_AfterCellListCloseUp(object sender, CellEventArgs e) { _dropdownShowing = false; }
void Grid_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (!_dropdownShowing) return; if (e.KeyValue == 13) { var vl=grid.DisplayLayout.ValueLists["myCustomList"]; if (vl.SelectedIndex <= 0) { vl.SelectedIndex = 0; } } }