We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Double Tab Keypress in User Control

I have a custom NumericUpDown I''ve built out of a textbox and a panel; the panel contains two buttons and the whole control has an imagelist. Everything is fine if I insert this control directly onto a form. However... If I put this control(call it NUD) onto another user control(call it UC1) (UC1 implements an interface), weirdness happens: The first time I set focus to a UC1 in a form, it requires me to press the tab key twice to tab to the next control. Any time after that (or if the initial focus was set by tabbing from another control into UC1), it only takes a single tab to tab to the next control on the form. The only tabbable part of UC1 is the textbox (all others have TabStop set to false). I used Spy++ on the textbox and those times it takes two tabs to get to the next control, it looks like the textbox is sending a WM_KILLFOCUS that sets the main control window of UC1 to have the focus, and then that main window is immediately setting the focus back to the textbox (textbox receives a WM_SETFOCUS). All other times the messages look right, with the textbox sending a WM_KILLFOCUS that sets focus to the next control on the form. Apparently, there can be a problem with having a panel on a user control (they inherit from different classes so their input handling is different: http://support.microsoft.com/default.aspx?scid=kb;en-us;820628); though that problem is a little different, I can''t help but wonder if they''re related. Does anyone have any ideas on what''s happening here?

Loader.
Live Chat Icon For mobile
Up arrow icon