How to programatically close a form which has a Font/Color Dialogopened

A

aagarwal8

Hi,

I have a form (say FormB) on which i have opened a font dialog. There
are situations when i need to close FormB, from another form (say
FormA) in my application. i am calling FormB.Close(), but the form
doesn't close. The moment i close the Font Dialog, FormB gets closed.
(Also, I observe the same behavior when i open other forms using
ShowDialog from FormB)

I need to find a way so that FormB closes as soon as i call
FormB.Close();

Regards,
Ankit
 
A

Andy

Hi,

I have a form (say FormB) on which i have opened a font dialog. There
are situations when i need to close FormB, from another form (say
FormA) in my application. i am calling FormB.Close(), but the form
doesn't close. The moment i close the Font Dialog, FormB gets closed.
(Also, I observe the same behavior when i open other forms using
ShowDialog from FormB)

I need to find a way so that FormB closes as soon as i call
FormB.Close();

Regards,
Ankit

I don't think this is possible. The only way it would work is if you
could somehow tell the modal dialog to close, and I'm not sure of a
way to get that.
 
I

ignacio machin

Hi,

I have a form (say FormB) on which i have opened a font dialog. There
are situations when i need to close FormB, from another form (say
FormA) in my application. i am calling FormB.Close(), but the form
doesn't close. The moment i close the Font Dialog, FormB gets closed.
(Also, I observe the same behavior when i open other forms using
ShowDialog from FormB)

I need to find a way so that FormB closes as soon as i call
FormB.Close();

Regards,
Ankit

Hi,

if the dialog is modal, how are you gonna clse it from another form?
Not only that, but IMHO closing a form without the user consent (or as
a response to an user action) is rude, very rude
 
A

aagarwal8

I don't think this is possible.  The only way it would work is if you
could somehow tell the modal dialog to close, and I'm not sure of a
way to get that.

Any, i have opened FormB on a separate thread. so i can have FormB
blocked with a modal dialog, but can still work on FormA (and thereby
initiate a close of FormB)

Regards,
Ankit
 
A

aagarwal8

Be that as it may, I agree with Andy that closing another form that's  
otherwise blocked by a modal dialog is not in keeping with the very  
excellent user-interface design "rule of least surprise".

If you really want to do this, you need to close the modal dialog first  
(as Andy already said).  Then you can close the form that opened the modal  
dialog.  Not that this is all that much nicer to the user, but at least  
it's less surprising than a form underneath a modal dialog disappearing  
while the modal dialog sticks around doing who knows what.

Pete

Pete,

I dont just want to close the FormB, but also the modal dialog/form
blocking it.
So it will never be a situation that the form disappears from the
background, and the modal window stands thr orphaned.

Ankit!
 

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