Whenever a cell is in edit mode, its hosted control is receiving the KeyDown event instead of the parent DataGridView that contains it That's why your keyboard shortcut is working whenever a cell is not in edit mode (even if it is selected), because your DataGridView control itself receives the KeyDown event. However, when you are in edit mode, the edit control contained by the cell is receiving the event, and nothing happens because it doesn't have your custom handler routine attached to it.
Whenever a cell is in edit mode, its hosted control is receiving the KeyDown event instead of the parent DataGridView that contains it. That's why your keyboard shortcut is working whenever a cell is not in edit mode (even if it is selected), because your DataGridView control itself receives the KeyDown event. However, when you are in edit mode, the edit control contained by the cell is receiving the event, and nothing happens because it doesn't have your custom handler routine attached to it.
I have spent way too much time tweaking the standard DataGridView control to handle edit commits the way I want it to, and I found that the easiest way to get around this phenomenon is by subclassing the existing DataGridView control and overriding its ProcessCmdKey function. Whatever custom code that you put in here will run whenever a key is pressed on top of the DataGridView, regardless of whether or not it is in edit mode. For example, you could do something like this: class MyDataGridView : System.Windows.Forms.
DataGridView { protected override bool ProcessCmdKey(ref System.Windows.Forms. Message msg, System.Windows.Forms. Keys keyData) { if ((keyData == (Keys.
Alt | Keys. S))) { //Save data } return base. ProcessCmdKey(msg, keyData); } } Also see related, though somewhat older, article: How to trap keystrokes in controls by using Visual C.
Good advice. The WM_KEYDOWN test isn't necessary btw. – Hans Passant Nov 26 '10 at 15:42 Thank you very much, for your advice – Javed Akram Nov 26 '10 at 16:08 @Hans Passant: I agree that it's not necessary, and I normally never include it.
I went back to add it after I saw that the article I linked to recommended it as a "good practice. " – Cody Gray Nov 26 '10 at 23:39 Typical KB verbiage. You won't know its BS until you put it to the test.0% hit so far.
– Hans Passant Nov 26 '10 at 0:08.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.