flynn Posted September 5, 2006 Posted September 5, 2006 (edited) The ESCAPE key can be trapped on a form by setting the "KeyPreview" property to true, but the user control does not have this property. Does anyone know how to trap a specific key on a user control, no matter what control on that user control has the focus? I need this functionality so that if the user presses the ESCAPE key, I can hide the user control until it is needed later. I'm guessing that a user control is treated exactly the same as a textbox control (or other control) in that there is no KeyPreview for those controls. I suppose I'll have to trap the ESCAPE key on the Form that contains the user control, then act accordingly, correct? tia, flynn Edited September 5, 2006 by flynn Quote
Cags Posted September 5, 2006 Posted September 5, 2006 Using one of the forms key events is the easiest way I can think of. I was considering suggesting attaching key events to the UserControls child controls and trap them that way, but I'm not sure if this would work correctly or be worth the effort. Still I've put the idea out there so you can give it a go if you want. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.