|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Application quit after button clickCan anyone please help me ? Ik would like to raise a messagebox after the close-icon is clicked, asking me if I'm sure to quit ... I'm using this code ... Private Sub myFormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) Select Case intResult Case intResult.Yes frmNext.Show() 'this form handles the quit Me.Show() End Select End Sub If i click on "no", the form hides itself, but the application is still running ... bummer.... john Sorry, i forgot some line of code ...
I'm using this code ... Private Sub myFormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) Select Case intResult Case intResult.Yes frmNext.Show() 'this form handles the quit Case inResult.No Me.Show() End Select End Sub If i click on "no", the form hides itself, but the application is still running ... bummer.... john you need to use "Handles Me.FormClosing" instead of "Handles
Me.FormClosed" John Devlon ha escrito: Show quoteHide quote > Sorry, i forgot some line of code ... > > I'm using this code ... > > Private Sub myFormClosed(ByVal sender As Object, ByVal e As > System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed > > Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit", > MessageBoxButtons.YesNo, MessageBoxIcon.Question, > MessageBoxDefaultButton.Button1) > > Select Case intResult > Case intResult.Yes > frmNext.Show() 'this form handles the quit > Case inResult.No > Me.Show() > End Select > End Sub > > If i click on "no", the form hides itself, but the application is still > running ... bummer.... > > john Hi John,
You need to write this code on 'Closing' event of the form instead of writing on 'Closed' event. Here in 'closing' event you can cancel the closing of the form just by using code of one line. e.Cancel = True This will cancel the closing event of the form. Your code will look like this: Private Sub myFormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.Closing Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) if intResult = intResult.No then e.Cancel = true 'Stops Closing of the Form end if End Sub Regards, Pragati Palewar Palewar Techno Solutions Windows Mobile & Palm Software Development Nagpur, India http://www.palewar.com
API FindFirstFile\FindNextFile vs GetFiles
How to Type cast ArrayList items to class objects Best practices for creating a "wizard" question about some good practises Question about 'Using' and resources Return DataRow VB 2005 with Active Directory User Controls basic question using com-port in VB.net use varible value in include file |
|||||||||||||||||||||||