473,414 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

detecting when focus leaves a form

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
1 1659
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the...
1
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
2
by: Dom Nicholas | last post by:
Hi, My question is this : how do I detect from another window which didn't create a new window whether it exists ? For example, is there a window-id's container of some sort that hangs around...
9
by: Fabian | last post by:
Is there a way to detect which object currently has the focus in javascript? "this" comes close, but isnt implemented in netscape. -- -- Fabian Visit my website often and for long periods!...
5
by: needin4mation | last post by:
Hi, I have an asp.net 1.1 application that populates data from a database. When the user changes data, they have to hit a button to update the data. The data entry form (same form that is...
1
by: Oenone | last post by:
We have a little piece of JavaScript in one of our client's application which automatically sets the input focus to the first control on the HTML form. This works very nicely, except for in one...
3
by: Greg | last post by:
The LostFocus event of datagrids is fired when the focus is added to a cell. How do you go about detecting it when the control as a whole has lost focus to another control? Slightly confused by...
3
by: Keith Wilby | last post by:
I have a form with 4 subforms on a tab control. How can I detect which sub/tab has the focus from the main form? Many thanks. Keith.
2
by: bobh | last post by:
Hi All, In AccessXP I have a form, it has a form header, detail and footer sections. When done entering text in a txtbox(bxReqst) in the footer the user wants to press the Tab key and have the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.