I have three forms. All forms are shown and I have a button on the third form. The button should close all the forms including the form where the button was created. Application.Exit() is not suitable for this because I don't want the application to exit including the forms that were not mentioned.
AngelicOne 4 Posting Whiz
Recommended Answers
Jump to PostCall the forms Close() methods of both forms.
If you no longer need the forms you cold call the Dispose() methods.
Jump to PostJust to add to ddanbe`s post:
But you need to have both instances avaliable and forms in state "Open", otherwise will be an error.You can set both Forms asd global and check if they are null whihle trying to close them:
//in form1: Form2 f2; …
Jump to PostLol, what is this code? You open and close all at once. Strange. There is no point in your code.
Jump to PostI`m far from being the best devepoler, still aloooong way to go.
About you uppe code snipet:
Yes it will close forms, but when? As I can see, just after opening them. So there is no point. Maybe you only wanted to show an example how to open and …
Jump to PostYou are welcome. btw, welcome to daniWeb.com!
Enjoy your staying.Mitja
All 22 Replies
ddanbe 2,724 Professional Procrastinator Featured Poster
Mitja Bonca 557 Nearly a Posting Maven
yousafc# 0 Junior Poster in Training
Mitja Bonca 557 Nearly a Posting Maven
yousafc# 0 Junior Poster in Training
Mitja Bonca 557 Nearly a Posting Maven
yousafc# 0 Junior Poster in Training
Mitja Bonca 557 Nearly a Posting Maven
AngelicOne 4 Posting Whiz
Mitja Bonca 557 Nearly a Posting Maven
AngelicOne 4 Posting Whiz
AngelicOne 4 Posting Whiz
Mitja Bonca 557 Nearly a Posting Maven
AngelicOne 4 Posting Whiz
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven
AngelicOne 4 Posting Whiz
Mitja Bonca 557 Nearly a Posting Maven
AngelicOne 4 Posting Whiz
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven
AngelicOne 4 Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.