By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,899 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,899 IT Pros & Developers. It's quick & easy.

detecting when focus leaves a form

P: n/a
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
Dec 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dean Slindee wrote:
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
Dec 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.