Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Go Back  Xtreme Visual Basic Talk > > > > Closing the Main Form , without Closing the Application.


Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2004, 03:35 PM
Csharp's Avatar
CsharpClosing the Main Form , without Closing the Application. Csharp is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Location: Ashby, Leicestershire.
Posts: 967
Wink Closing the Main Form , without Closing the Application.


Hi guys n gals , i have knocked up a little bit of code which may provide usefull.
i guess most people are aware that if you try closing your Main Form, while trying to leave a second Form open ( ie: Form2.Show , Form1.Close ) , you end up with the Application closing completely. well not anymore
in a Module ( with a Sub Main set as the Start-up object ) ...
Code:
'/// add a module to your application , then set it's Sub Main as your start-up object Imports System.Windows.Forms Module Module1 Sub main() Dim frmMain As New Form1 frmMain.Show() Application.Run() '/// NOTE : i run the application without a start-up Main form. End Sub End Module
in Form1 ( which will load as your default form in this instance ) ...
Code:
Private closeApp As Boolean = True Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click closeapp = False Dim frm2 As New Form2 frm2.Show() Me.Close() End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If closeApp Then Application.Exit() End If End Sub
Form2 will now show and Form1 will close without the Application exiting , in form2 , to close the app i put a simple ...
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Application.Exit() End Sub
included is a sample source.
Attached Files
File Type: zip Project1.zip (4.7 KB, 174 views)
__________________
~~ please don't PM me regarding code, I only reply to personnal messages ~~
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
closing a word application!! sonia General 1 01-03-2004 07:15 AM
Closing access application - clicking X on top right rajanikanth_r Word, PowerPoint, Outlook, and Other Office Products 0 12-23-2003 12:13 AM
disable print preview from xlDialogPrint w_seyller Excel 9 12-11-2003 11:20 AM
Creating a filter by Form?? john_mcdowell Database and Reporting 0 01-20-2003 07:51 PM
Changing Display in Main Form velicity13 General 16 03-03-2002 05:50 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application. Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
 
Closing the Main Form , without Closing the Application.
Closing the Main Form , without Closing the Application.
 
-->