.netwinformskeypresskeydownsuppress

.NET WinForms KeyEventArgs.SuppressKeyPress: effect of setting it to True in the KeyUp event


The KeyEventArgs class in WinForms implements the Boolean SuppressKeyPress property. KeyEventArgs provides data for the KeyDown and KeyUp events. The SuppressKeyPress property can be set to True in a KeyDown event handler to suppress the subsequent KeyPress event - this purpose is clear. But is there any effect of setting SuppressKeyPress to True in event handlers of the KeyUp event?


Solution

  • I totally agree with all commenters that SuppressKeyPress is absolutely useless in KeyUp. As @Jimi explained, this field appears in KeyUp only because of the specific internal architecture of the Control class.