Hi,
In my application some key presses are captured by accelerators and translated into the appropriate command. For instance CTRL+C is mapped to the ID_EDIT_COPY command. I am able to capture these commands in my C# UltraGrid wrapper assembly and get them to the grid by calling for instance....
m_grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.Copy);
However, I need to be able to simulate clicking the Delete key in the grid when it is in edit mode. I do not see any actions in the PerformAction method that would send a key press to the grid.
I have tried using the PostMessage API call with WM_KEYDOWN but this caused the grid to hang ?
Any recommendations ?
The grid uses out embeddable editor architecture so when a cell is in edit mode, you can usually use the properties and methods of the EmbeddableEditorBase class (from which all embeddable editors derive) to manipulate the cell's current value. For example, if you wanted to clear the text out of an EditorWithText, you could set the editor's Value property to an empty string. It is possible that you can solve your problem in this manner without having to simulate typing the Delete key.
To answer your question, you can use the SendKeys class to simulate user keyboard interactivity.
Hi Brian,
Thanks for the prompt reply. Just calling SendKeys.SendWait("{DEL}") is working for me. This means that if the user is editing some text in the grid the delete key press is handled correctly whereas if they have selected an entire row it asks if they want to delete the row.
So the grid makes the right decision as how to handle it rather than me having to code up context specific code.
The problems I am encountering are due to the fact that we have the grid hosted in a .NET assembly within an MFC application - lots of fun.
Thanks again for your help.