B
BoloBaby
OK, check this out...
I have a form with a panel control and button on it (outside the panel
control).
I have two event handlers - one handles the click event of the button on the
form. The other handles a custom "CardInserted" event for a class I wrote
that watches for smart cards to be inserted into an attached smart card
reader.
BOTH event handlers have the *exact* same code in them - which is to add a
new button control into the panel control whenever the event fires.
The code for the button's click event works just fine - buttons get added to
the panel control without any problem.
The code for my "CardInserted" event - which is the EXACT same code as the
button.click code does NOT work. The event gets raised (verified), the code
runs (verified), but it STOPS running at the panel.controls.add(newbutton)
line. It doesn't throw an error, it just stops running and no button gets
added. The program continues to run and I can keep adding buttons to the
panel control via the form's button.click, but the "CardInserted" code
simply will not run - *despite being the same code as the button.click
code*!
I tried swapping out the panel.controls.add(newbutton) line with a simple
"msgbox panel.controls.count" and that works just fine - so I can see the
panel control from the CardInserted event. I can even do a
"panel.controls.remove" command if I want - I just can't ADD a new control
during my CardInserted event handler.
I'm totally confused. Why would I be unable to run code that works for
button.click under my CardInserted event handler? The ONLY thing I can't do
is add a control.
Why is this? Is it a bug in the panel control?
I have a form with a panel control and button on it (outside the panel
control).
I have two event handlers - one handles the click event of the button on the
form. The other handles a custom "CardInserted" event for a class I wrote
that watches for smart cards to be inserted into an attached smart card
reader.
BOTH event handlers have the *exact* same code in them - which is to add a
new button control into the panel control whenever the event fires.
The code for the button's click event works just fine - buttons get added to
the panel control without any problem.
The code for my "CardInserted" event - which is the EXACT same code as the
button.click code does NOT work. The event gets raised (verified), the code
runs (verified), but it STOPS running at the panel.controls.add(newbutton)
line. It doesn't throw an error, it just stops running and no button gets
added. The program continues to run and I can keep adding buttons to the
panel control via the form's button.click, but the "CardInserted" code
simply will not run - *despite being the same code as the button.click
code*!
I tried swapping out the panel.controls.add(newbutton) line with a simple
"msgbox panel.controls.count" and that works just fine - so I can see the
panel control from the CardInserted event. I can even do a
"panel.controls.remove" command if I want - I just can't ADD a new control
during my CardInserted event handler.
I'm totally confused. Why would I be unable to run code that works for
button.click under my CardInserted event handler? The ONLY thing I can't do
is add a control.
Why is this? Is it a bug in the panel control?