I have a UltraGrid column of type string.
I set a ValueList property of the UltraGridColumn that I get through the UltraGrid's DisplayLayout.
After the user selects an item in the drop down, the grid puts the cursor in the cell to allow editing.
The user has to hit 'ENTER' after selecting the drop down for the edit to raise the change event.
How can I make the change event get raised when the selection finishes with out requiring the user to also hit enter...
I want the edit applied on the select and the change raise immediately...
by the way here is the event I would like raise.
It does not happen when I select from the drop down, only when I confirm it with enter
> MgdScene.dll!MgdScene.CharacterCLT.WeaponFile.set(string value = "weapon-AK47") Line 262 C# [Native to Managed Transition] [Managed to Native Transition] System.dll!System.ComponentModel.ReflectPropertyDescriptor.SetValue(object component = {MgdScene.CharacterCLT}, object value = "weapon-AK47") + 0x124 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridRow.SetCellValue(Infragistics.Win.UltraWinGrid.UltraGridColumn column = {WeaponFile}, object val = "weapon-AK47", bool suppressErrorMessagePrompt = false, bool throwExceptionOnError = false, bool fireDataChanged = true, bool fireCellUpdateEvents = false) + 0x8b3 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridRow.SetCellValue(Infragistics.Win.UltraWinGrid.UltraGridColumn column = {WeaponFile}, object val = "weapon-AK47", bool suppressErrorMessagePrompt = false, bool throwExceptionOnError = false, bool fireDataChanged = true) + 0x46 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridRow.SetCellValue(Infragistics.Win.UltraWinGrid.UltraGridColumn column = {WeaponFile}, object val = "weapon-AK47", bool suppressErrorMessagePrompt = false, bool throwExceptionOnError = false) + 0x43 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.SetValueInternal(object value = "weapon-AK47", bool suppressErrorMessagePrompt = false, bool fireInitializeRow = false, bool throwExceptionOnError = false, bool fireDataChanged = true) + 0x428 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.SetValueInternal(object value = "weapon-AK47", bool suppressErrorMessagePrompt = false, bool fireInitializeRow = false, bool throwExceptionOnError = false) + 0x45 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.SetValueInternal(object value = "weapon-AK47", bool suppressErrorMessagePrompt = false, bool fireInitializeRow = false) + 0x31 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.CommitEditValue(ref bool stayInEdit = false, bool fireDataError = true, bool forceDontThrowException = false, bool dontStoreInUndoHistory = false) + 0xa97 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.CommitEditValue(ref bool stayInEdit = false, bool fireDataError = true, bool forceDontThrowException = false) + 0x31 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridLayout.OnEditorBeforeExitEditMode(object sender = {Infragistics.Win.EditorWithCombo}, Infragistics.Win.BeforeExitEditModeEventArgs e = {Infragistics.Win.BeforeExitEditModeEventArgs}) + 0x1d9 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EmbeddableEditorBase.OnBeforeExitEditMode(ref bool cancel = false, bool forceExit = false, bool applyChanges = true) + 0x97 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EditorWithText.OnBeforeExitEditMode(ref bool cancel = false, bool forceExit = false, bool applyChanges = true) + 0x5a bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EditorWithCombo.OnBeforeExitEditMode(ref bool cancel = false, bool forceExit = false, bool applyChanges = true) + 0x30 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EmbeddableEditorBase.ExitEditMode(bool forceExit = false, bool applyChanges = true) + 0x2cd bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.ExitEditMode(bool cancellingEditOperation = false, bool forceExit = false) + 0x160 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.ExitEditMode() + 0x23 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGrid.ClearActiveCell(bool invalidate = true, bool shutdown = false) + 0x58 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGrid.OnActiveRowCleared(bool update = true) + 0x94 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridBase.SetActiveRow(Infragistics.Win.UltraWinGrid.UltraGridRow row = {Infragistics.Win.UltraWinGrid.UltraGridRow}, bool scrollIntoView = false) + 0x208 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.Activate() + 0x1ca bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.SetFocusAndActivate(bool byMouse = true, bool enterEditMode = false, bool byTabKey = false) + 0x8e bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridCell.SetFocusAndActivate() + 0x2b bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGrid.Infragistics.Win.ISelectionManager.ActivateItem(Infragistics.Shared.ISelectableItem item = {Infragistics.Win.UltraWinGrid.UltraGridCell}) + 0x37 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.SelectionStrategyExtended.ProcessKeyBoardItem(Infragistics.Shared.ISelectableItem item = {Infragistics.Win.UltraWinGrid.UltraGridCell}, bool shift = false, bool control = false, bool forceToggle = false) + 0xa6 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridLayout.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction actionCode = NextCellByTab, bool shiftKeyDown = false, bool ctlKeyDown = false) + 0xc95 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGrid.PerformKeyAction(System.Enum actionCode = NextCellByTab, bool shiftKeyDown = false, bool ctlKeyDown = false) + 0x12a bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridUIElement.PerformKeyAction(System.Enum actionCode = NextCellByTab, bool shiftKeyDown = false, bool ctlKeyDown = false) + 0x3d bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.ControlUIElementBase.ProcessKeyDown(object sender = {Infragistics.Win.UltraWinGrid.UltraGridUIElement}, System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x168 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.ControlUIElementBase.ProcessKeyDown(System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x28 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridUIElement.ProcessKeyDown(System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x6c bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.Utilities.ProcessEvent(System.Windows.Forms.Control control = {Infragistics.Win.UltraWinGrid.UltraGrid}, Infragistics.Win.ControlUIElementBase.ProcessEvent eventToProcess = KeyDown, System.EventArgs e = {KeyData = LButton | MButton | Back}) + 0x2b5 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.UltraControlBase.OnKeyDown(System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x5c bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridBase.EditorContainerControlOnKeyDown(System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x28 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridBase.OnKeyDownForwarded(System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x4b6 bytes Infragistics2.Win.UltraWinGrid.v11.1.dll!Infragistics.Win.UltraWinGrid.UltraGridLayout.OnEditorKeyDown(object sender = {Infragistics.Win.EditorWithCombo}, System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x47 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EmbeddableEditorBase.RaiseKeyDownEvent(System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x3d bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EmbeddableTextBox.OnKeyDown(System.Windows.Forms.KeyEventArgs e = {KeyData = LButton | MButton | Back}) + 0x65 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EmbeddableTextBoxWithUIPermissions.ProcessKeyMessage(ref System.Windows.Forms.Message msg = {msg=0x100 (WM_KEYDOWN) hwnd=0x8a08a4 wparam=0xd lparam=0x1c0001 result=0x0}) + 0x2f5 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WmKeyChar(ref System.Windows.Forms.Message m = {msg=0x100 (WM_KEYDOWN) hwnd=0x8a08a4 wparam=0xd lparam=0x1c0001 result=0x0}) + 0x15 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x7dd bytes System.Windows.Forms.dll!System.Windows.Forms.TextBoxBase.WndProc(ref System.Windows.Forms.Message m) + 0x37 bytes System.Windows.Forms.dll!System.Windows.Forms.TextBox.WndProc(ref System.Windows.Forms.Message m) + 0x36 bytes Infragistics2.Win.v11.1.dll!Infragistics.Win.EmbeddableTextBoxWithUIPermissions.WndProc(ref System.Windows.Forms.Message m = {msg=0x100 (WM_KEYDOWN) hwnd=0x8a08a4 wparam=0xd lparam=0x1c0001 result=0x0}) + 0x197 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0x10 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x31 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 256, System.IntPtr wparam, System.IntPtr lparam) + 0x57 bytes [Native to Managed Transition] [Managed to Native Transition] System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason = -1, int pvLoopData = 0) + 0x24e bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0x177 bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x31 bytes ScenarioEditor.exe!ScenarioEditor.Program.Main(string[] args = {Dimensions:[0]}) Line 57 + 0x2c bytes C# [Native to Managed Transition] [Managed to Native Transition] mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x3a bytes Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2b bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x66 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
Hi,
I'm really not sure what event you are referring to. There is no Change event on the grid. Are you asking about a grid event or an event on some other object?
The grid doesn't commit the changes to a cell on every keystroke or when you pick from the list, because that would be very inefficient and dangerous. The user might change his mind and pick something else and so any processing you do at that point would have been wasted.
Also, for some types of cells, updating on every change would not work. Take, for example, a DateTime cell. As the user is typing, what they type initially isn't a valid date at all, until they type a certain number of characters.
There's a CellChange event on the grid that fires on every keystroke (or when you select a ValueListItem) but the Value of the cell will not (and really cannot) reflect the change at this point, since it might not be valid. You have to use the Text property of the cell to get the actual on-screen text of the cell.
The grid writes changes to the data source based on the UpdateMode property. By default, this happens when you leave the cell or the grid control loses focus.
If you want to force an update manually, you can call the UpdateData method on the row (to commit all changes in the row) or the Update method on the grid (to commit all changes to all rows). But, of course, this method can fail in some cases if the user is in the middle of editing. That's probably not a problem in this case.
There is also a CellListSelect event on the grid. This is similar to CellChange, in that the Value property will not have been updated when it fires and you have to use Text.
yes this lets the user select the date item from the list and immediately sets the property of the item in binding list on user click in the ValueList.
Thanks!
m_grid.CellListSelect += new CellEventHandler(Grid_CellListSelect);...
void Grid_CellListSelect(object sender, CellEventArgs e){ if (null == e.Cell.Column.ValueList) return;
// force data commit on list item click // do not wait for the // default edit behavior // of waiting for the user to hit 'ENTER' e.Cell.Row.Update(); }
Hi Karl,
metavr said:to clarify - I receive the event from the ultragrid when a bound record has is poperty set. In turn I raise events to notify the rest of the system of the change.
I still don't know what event you are referring to. But I don't think it matters.
If you know that the user must select from the list and that every choice that can make is always valid, then you could force the grid to commit the changes. What you would do is handle CellListSelect or CellChange in the grid and trap for changes in that one particular column (or columns) and then you can force the grid to commit the changes by calling Update on the row.
The problem with this is that it will commit all changes in the row, not just the one for this particular column. This is probably not a big deal, since the grid probably committed the change to any other cells in the same row when the user left that cell, anyway.
Hello Karl,
After reading Mike's post and yours, I believe that the CellListSelect event is your best option. Please let us know if you have any other questions about this.
"I'm really not sure what event you are referring to. There is no Change event on the grid. Are you asking about a grid event or an event on some other object?"
to clarify - I receive the event from the ultragrid when a bound record has is poperty set. In turn I raise events to notify the rest of the system of the change.
This causes other parts of the UI to update.
this.ultraGrid1.DataSource = new BindingList<MyRecord>(_recordList)
where
class MyRecord{
string _weapon;
public string WeaponColumn {
get { return _weapon; }
set { _weapon = value;
// notify the rest of the system from here
}
"The grid doesn't commit the changes to a cell on every keystroke or when you pick from the list, because that would be very inefficient and dangerous. The user might change his mind and pick something else and so any processing you do at that point would have been wasted."
It depends on what is in the cell and the expected user interaction.
In my case the ValueList is a list of atomic items. In the currently implementation, the user has to select from a drop down with the mouse, and then reach back with the key board and press 'ENTER' with the keyboard to confirm that yes in fact he really did mean it when he clicked the drop down with the mouse. From the user perspective, selecting from the drop down should trigger the update, with no extra confirming 'ENTER'. We know that the data is valid because he just selected it from the dropdown.
"There is also a CellListSelect event on the grid. This is similar to CellChange, in that the Value property will not have been updated when it fires and you have to use Text."
ok I will explore taking the notify out of the record set and hijacking using this as a work around.
Thanks
Karl