Trap leave and closing Form that place in TabPage

M

mtczx232

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?
 
R

rowe_newsgroups

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
 
M

mtczx232

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.
 
R

rowe_newsgroups

That exactly I claim. the FormClosing event in the inner form (place
on TabPage), is not fired while main form closing!?


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
 

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