key events in a winforms custom control class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ncscoots
    New Member
    • Dec 2014
    • 1

    key events in a winforms custom control class

    I've been building my own nullable and bindable datetimepicker class, which inherits from DateTimePicker and includes a textbox to handle any user text entry, blanking the date for null, and such. Works great and handles all my needs just fine, except for one thing: key events when the calendar is dropped down. I wanted to capture the Enter key (which would set the control value to the dtp value; and the Escape key (which would leave the control value unchanged). I'm doing all the synchronization work between Mybase.Value and the control's value at the CloseUp event and figured it would be no sweat to intercept the key events and set some flags to whatever I wanted. But no go. I've tried 'em all, from PreviewKeyDown to ProcessCmdKey and everything in between, and I never get one before Closeup. I'm sure I'm missing something simple, but have no idea what.
Working...