winforms - Close PrintPreviewDialog when ESC is pressed -
I'm working on a WinForms application using System.Windows.Forms.PrintPreviewDialog
when the
Print Preview dialog for the user to turn the presses communicate ESS, so I communicate. Unfortunately, I can not understand how to do this. I have tried to set up a KeyDown / PreviewKeyDown event handler, but it is sometimes not even call I also tried setting the focus for dialogue (and to its PrintPreviewControl), it was the issue thinking , But that did not help either that Anyone have any idea how to work it?
I ended up to overriding off customizing and his method is made when the user presses ESC. It seems like a clean solution
Here's the code that I wrote:
using System.Windows.Forms; Namespace MyProject.UI.Dialogs {square CustomPrintPreviewDialog: PrintPreviewDialog {protected override bool ProcessCmdKey (reference message, key keyData) {When the user presses the off ESC // dialog box, (keyData == Keys.Escape) {this. Close (); Back true; } Return Base Processcmdk (riff message, keydata); }}}