[program-l] Binding keydown event to dynamically generated textbox

  • From: Jacob Kruger <Jacob.Kruger@xxxxxxxxxxxx>
  • To: "program-l@xxxxxxxxxxxxx" <program-l@xxxxxxxxxxxxx>
  • Date: Tue, 27 Oct 2009 14:51:24 +0200

Ok, next question.

If I dynamically create and place textbox controls on my form, within a tab 
control, they don't seem able to capture the keydown event, which the combo 
boxes created in the similar routine are fine with?

If I drop a standard textbox on a windows form during design, I can then quite 
easily capture it's keydown event, but for some reason this doesn't seem to 
want to work on my runtime generated textboxes, but I want to be able to also 
catch the necessary keystrokes to be able to 'trash' the currently focused 
textbox, using something like a key combo of Alt + T, but I just hear the 
invalid sound when I hit that keystroke in there?

I am using the same basic code to link their events to my subroutine:
ctlTB.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textbox_KeyDown);

Stay well

Jacob Kruger
jacob.kruger@xxxxxxxxxxxx


** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts:

  • » [program-l] Binding keydown event to dynamically generated textbox - Jacob Kruger