.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Close others forms in windows application

Posted By: Shweta     Posted Date: May 06, 2010    Points:2   Category :Windows Application
Hi,

how to close all the other windows form in windows application except the main form in button click event?



Responses
Author: Lalij Mer             
Posted Date: May 06, 2010     Points: 5   

Hi,

Shweta Get here solution


http://devcity.net/articles/94/1/.aspx

Please Check my answer if you help....
Thank You...

Lalit.
Author: Santosh          Accepted Answer   
Posted Date: May 07, 2010     Points: 10   

Hi Shweta,

I don't know u r working in vb.net or c#.net.
any way my code is in vb.net,
try below code,i think u will get ur solution.


Code:

Private Sub CloseAllForms_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseAllForms.Click
If (My.Application.OpenForms.Count - 1) > 0 Then
For i As Integer = 0 To My.Application.OpenForms.Count - 2
If My.Application.OpenForms.Count > 1 Then
My.Application.OpenForms.Item(My.Application.OpenForms.Count - 1).Close()
End If
Next
End If
End Sub



Any problem plz Reply......

Regards
Santosh


Author: Shweta             
Posted Date: May 10, 2010     Points: 5   

Thanks Santosh..Its working..

Regards,
Shweta

Author: krishana singh             
Posted Date: December 04, 2010     Points: 5   

Form f = this.ActiveMdiChild;
if (f != null)
f.Close();
frmBooking f1 = new frmBooking(); ;
f1.MdiParent = this;
//f1.WindowState = FormWindowState.Maximized;
f1.Show();

Author: krishana singh             
Posted Date: December 07, 2010     Points: 5   

//Form f = this.ActiveMdiChild;
//if (f != null)
// f.Close();
//frmAttendance f1 = new frmAttendance();
//f1.MdiParent = this;
//f1.WindowState = FormWindowState.Maximized;
//f1.Show();



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend