Tabpage knowing when the Parent Form is closing?

Posted on 2009-04-30
Medium Priority
Last Modified: 2012-05-06
I have a tabpage within a form that I need information to be saved before people can close out of it.

The problem I am having is that the while the user can fill out the form I cannot prevent them from hitting the X in the top right corner and losing the data they have saved.

So how would I capture his OnClose event from within a tabpage?
Question by:directxBOB

Accepted Solution

alex_paven earned 2000 total points
ID: 24268729
Assuming this is a windows forms project, it's incorrect to say 'from within the tabPage' because it does not have it's own code; the code is contained in the parent form.
To prevent/ask the user to save first, handle the FormClosing event of the form. Then you can do something like the code below, of course you can elaborate with a dialog asking the user to save, as is customary.

  void Form1_FormClosing(object sender, FormClosingEventArgs e)
    if (!saved) e.Cancel = true; //cancel closing

Open in new window

LVL 26

Expert Comment

by:Anurag Thakur
ID: 24269636
lot of links for how to handle your requirement in web forms

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question