Sams Teach Yourself C# in 24 Hours

Sams Teach Yourself C# in 24 Hours

By James Foxall and Wendy Haro-Chun

Q&A

  1. Is it possible to capture keystrokes at the form level, rather than capturing them in control events?

    Yes. For the form's keyboard-related events to fire when a control has the focus, however, you must set the form's KeyPreview property to true. The control's keyboard events will still fire, unless you set KeyAscii = 0 in the form's KeyPress event and KeyCode = 0 in the form's KeyDown event.

  2. You don't seem to always specify a button in your MessageBox.Show() statements throughout this book. Why?

    If you don't explicitly designate a button or buttons, C# displays the OK button. Therefore, if all you want is an OK button, you do not need to pass a value to the buttons argument.

Share ThisShare This

Informit Network