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

Trap leave and closing Form that place in TabPage

P: n/a
I have TabControls that Hold Forms on his TabPges (this make me easy
to give ability to Designing each form in his IDE window).
When form x is in middle of Edit Data Mode, I going to prevent:
Closing App or switch to other tabs until save done explicit by user.
So I try use events like:
deactivate,leave,lostfocus,formclosing,validating to prevent user
leave before save. but no one work:

the [deactivate,leave,lostfocus,formclosing] not fire at all when app
closing or switch to other tabs
the Validating fire, but when (there no change if i set e.cancel =
true or e.cancel = false) user switch to othet tab we got unexpected
behavior: the validating fire 3 times and switch to next tab, now the
validating fire again and again as respond to any click on App window!

this is bug?

Oct 9 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Oct 9, 2:43 am, mtczx...@yahoo.com wrote:
I have TabControls that Hold Forms on his TabPges (this make me easy
to give ability to Designing each form in his IDE window).
When form x is in middle of Edit Data Mode, I going to prevent:
Closing App or switch to other tabs until save done explicit by user.
So I try use events like:
deactivate,leave,lostfocus,formclosing,validating to prevent user
leave before save. but no one work:

the [deactivate,leave,lostfocus,formclosing] not fire at all when app
closing or switch to other tabs
the Validating fire, but when (there no change if i set e.cancel =
true or e.cancel = false) user switch to othet tab we got unexpected
behavior: the validating fire 3 times and switch to next tab, now the
validating fire again and again as respond to any click on App window!

this is bug?
I'm sorry if I misunderstand you, your english is barely
comprehendable.
>From what I read you are trying to trap two actions. First, you want
to know when the form closes, and secondly you want to know when the
selected tab changes right?

To trap when the form is closing, you must subscribe to the
FormClosing event of the parent form.

To trap when a different tab is selected, you can subscribe to the
TabControl's SelectedIndexChanged event.

Thanks,

Seth Rowe

Oct 9 '07 #2

P: n/a
>
to know when the form closes, and secondly you want to know when the
selected tab changes right?
That exactly I claim. the FormClosing event in the inner form (place
on TabPage), is not fired while main form closing!?
To trap when the form is closing, you must subscribe to the
FormClosing event of the parent form.
According the engineering approach, we preferring to build modular
code. the form that contain the ControlTab is not know the Inner form.
so the right place to prevent leave the inner Form without saving is
the Inner form itself. but no way to trap it.

Oct 10 '07 #3

P: n/a
On Oct 10, 3:34 am, mtczx...@yahoo.com wrote:
to know when the form closes, and secondly you want to know when the
selected tab changes right?

That exactly I claim. the FormClosing event in the inner form (place
on TabPage), is not fired while main form closing!?
To trap when the form is closing, you must subscribe to the
FormClosing event of the parent form.

According the engineering approach, we preferring to build modular
code. the form that contain the ControlTab is not know the Inner form.
so the right place to prevent leave the inner Form without saving is
the Inner form itself. but no way to trap it.
Could you give me some sample code that creates the form, the "inner
form", and the tabcontrol? I'm still not quite understanding what you
are saying, and some sample code would give me something to work with.

Thanks,

Seth Rowe

Oct 10 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.