Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by flynn
Posted
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.
Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...