Dynamically Added Textbox (no KeyDown, KeyUp, KeyPress events fire)

  • Thread starter Thread starter Doug Perkes
  • Start date Start date
D

Doug Perkes

I am having a strange problem with a textbox that I am dynamically
adding to a form.

What I am currently doing
-------------------------
I have a set of questions defined in a database. Each question can have
a variable number of possible responses and can be laid out
differently.

I have an answer factory class that gets the correct answer control
(RadioButton, TextBox, CheckBox) and provides it to a question control.
The question control then adds the answer to one of its panels. All
this seems to work a designed...I can add any number of questions and
answers to a question list control in a variety of different layouts.

The Problem I am Encountering
-------------------------
The problem occurs with textbox controls. They display correctly,
however, the KeyDown, KeyUp, and KeyPress events are not firing for the
textboxes (in other words, I can't type anything into the textbox).

However, if I have 2 textbox controls in the same container (panel), I
can always get the KeyUp, KeyPress, and KeyDown events to fire by
tabbing from the first textbox to the second. Once I do this, I can
then start typing into both textboxes without problem.
I am completely stumped.

Thanks for your help,

Doug
 
Well, I haven't been able to recreate the problem in another app but I
have discovered one more thing: if I use the TAB key to navigate to
the textboxes from other controls, the textbox behaves normally.
However, if I use the mouse to click in the textbox the KeyUp,
KeyDown, etc events do not fire.

This is a strange one.
 
Back
Top