Results 1 to 6 of 6

Thread: Is there a form close or try to close event?

  1. #1

    Thread Starter
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    Is there a form close or try to close event?

    what can I use to "show do you want to save the file" msgbox
    is there a on form close event or something, I couldnt find anything
    If the form's close buttone is closed it should ask if we want to save the file or not, if the user want to save the file the save function should be called

  2. #2
    Fanatic Member Loraine's Avatar
    Join Date
    Aug 2006
    Location
    8ft. underground
    Posts
    581

    Re: Is there a form close or try to close event?

    Code:
      
     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            MsgBox ("Do you want to save the file?", Msgboxstyle.YesNo + MessageBoxIcon.Question)
    
        End Sub

  3. #3
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: Is there a form close or try to close event?

    Probably want to start using MessageBox.Show

    vb Code:
    1. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) _
    2.     Handles Me.FormClosing
    3.  
    4.         Select Case MessageBox.Show("Would you like to save the form before closing?", "Close?", MessageBoxButtons.YesNo)
    5.  
    6.             Case Windows.Forms.DialogResult.Yes
    7.  
    8.                 'e.Cancel = True  'Not really needed but you may want it
    9.                 'Save info here
    10.  
    11.  
    12.  
    13.             Case Windows.Forms.DialogResult.No
    14.  
    15.                 e.Cancel = False
    16.         End Select
    17.  
    18.     End Sub
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  4. #4
    Fanatic Member Loraine's Avatar
    Join Date
    Aug 2006
    Location
    8ft. underground
    Posts
    581

    Re: Is there a form close or try to close event?

    and you can put a "SaveFileDialog1" Control so you can able to save your Windows Application .... ^^

  5. #5

    Thread Starter
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    Re: Is there a form close or try to close event?

    thanks a lot guys that worked perfectly
    guys and girls sorry!

  6. #6

    Thread Starter
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    Re: Is there a form close or try to close event?

    resolved
    Last edited by ethicalhacker; Apr 22nd, 2007 at 10:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width