Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Usercontrol Capture KeyDown

Status
Not open for further replies.

JurkMonkey

Programmer
Nov 23, 2004
1,731
CA
Hi,

I have a usercontrol that is trying to capture the keydown event but it is not firing.

Basically, I have a usercontrol that contains other usercontrols. (Its a thumbnail picker)

I want to be able to hold down the "Control" key and notify my container usercontrol that MultiSelect is required. For some reason, the keydown event is not firing.

Any ideas?
 
Ok, so I figured it out.

I have an image and a label control, both of which don't accept the keydown or keyup event. So when I add the usercontrols (thumbnails) to my container usercontrol, the thumbnail was getting the focus - and when it creates its controls, one of its controls gets focus and therefore, the messages aren't captured.

To fix this, after I add the thumbnail to my container control, I set the container control to have focus.


In my container usercontrol I have:

public void AddThumbnail(UserControl thumbnail)
{
this.Controls.Add(thumbnail);
this.Focus();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top