detecting when focus leaves a form

D

Dean Slindee

In my application there is a main form with a tabcontrol. On each page in
the tabcontrol is a panel upon which is painted a "sub" form. The main form
acts as the "application host", while the subforms are where data values
contained in underlying tables are displayed, inserted, updated or deleted.


I don't make the user press an "Edit" button to enable the textboxes on the
subforms. Rather, the subforms and their textboxes are always in edit mode.
However, the user must remember to press the Update, Insert or Delete button
to make any changes keyed into the subform affect the underlying database.


Simple enough, but not completely foolproof given inept or careless users.
Therefore, I would like to implement a reminder process using a dialog box.
So that, when the user makes a change to any "data-enabled" control
(textbox, checkbox, combobox, etc), a form-level boolean variable becomes
"dirty". This code I have written and tested ok.

My problem is in detecting when the user has decided to move off the "dirty"
form. I thought that I could detect this action in code placed in the
form_LostFocus event. Problem is, the code is in the LostFocus event, but
the event is not being fired. Is this normal? Is there another way to
detect moving off a form?

Thanks in advance,

Dean Slindee
 
C

Chris

Dean said:
In my application there is a main form with a tabcontrol. On each page in
the tabcontrol is a panel upon which is painted a "sub" form. The main form
acts as the "application host", while the subforms are where data values
contained in underlying tables are displayed, inserted, updated or deleted.


I don't make the user press an "Edit" button to enable the textboxes on the
subforms. Rather, the subforms and their textboxes are always in edit mode.
However, the user must remember to press the Update, Insert or Delete button
to make any changes keyed into the subform affect the underlying database.


Simple enough, but not completely foolproof given inept or careless users.
Therefore, I would like to implement a reminder process using a dialog box.
So that, when the user makes a change to any "data-enabled" control
(textbox, checkbox, combobox, etc), a form-level boolean variable becomes
"dirty". This code I have written and tested ok.

My problem is in detecting when the user has decided to move off the "dirty"
form. I thought that I could detect this action in code placed in the
form_LostFocus event. Problem is, the code is in the LostFocus event, but
the event is not being fired. Is this normal? Is there another way to
detect moving off a form?

Thanks in advance,

Dean Slindee

Do you actually have a form residing inside a panel on a tab control?
Have you tried using the Panel.LostFocus event? If it is actually a
form, look at using the Deactivate event.

How do you "paint a "sub" form"?

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top