Timeline for answer to Handle navigation keys in TextBox inside DataGridView by vito
Current License: CC BY-SA 4.0
Post Revisions
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 24, 2020 at 14:26 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Active reading.
|
| Aug 8, 2018 at 20:29 | vote | accept | ASh | ||
| Aug 2, 2018 at 18:38 | history | edited | vito | CC BY-SA 4.0 |
After reading the article [Notes to Inheritors](https://msdn.microsoft.com/en-us/library/system.windows.forms.control.processkeymessage(v=vs.110).aspx), I have changed code to return value from call 'ProcessKeyEventArgs'.
|
| Aug 2, 2018 at 18:36 | comment | added | vito | But you are right. I have an error in my code. I should not simple return value false. After reading the article Notes to Inheritors, I have changed code to return value from call 'ProcessKeyEventArgs'. | |
| Aug 2, 2018 at 18:34 | comment | added | vito | After pressing the key, the DGW is first to process the key and the textbox is the second. When I write some text into textbox, the DGW does not process keys. The return value of 'ProcessKeyPreview' of DGW is false. But when I press key 'home' or 'left arrow', the DGW process the key through 'ProcessDataGridViewKey' and return true. | |
| Aug 2, 2018 at 18:33 | comment | added | vito | I looked closer to how DataGridView and TextBox handle the keys. When the datagridview is empty (without columns), then the textbox has the expected behavior. But when DGW has columns and some rows, then the textbox does not respond to some keys like home, end, left... I thing, it is because the DGW row has focus. | |
| Aug 2, 2018 at 17:32 | comment | added | ASh |
ok, it seems to work. and replacing TextBox with its derived class is a local change in our QuickSearch feature, hidden by incapsulation, no need in external changes. but it is unclear to me - why it works? docs for ProcessKeyMessage says "a control should return true to indicate that it has processed the key". but here MyTextBox returns false (not processed) and then text selection works somehow?! does it trigger TextBox processing?
|
|
| Aug 2, 2018 at 8:56 | history | answered | vito | CC BY-SA 4.0 |