VB.NET Closing 共用


有點無言,被騙了..
還是我根本沒深入過?還是我忘了..終於將離開的按鈕連到原來的事件上..

原還以為要用到 addhandler 和 addressof 的..誰不知道只要直接來個 me.close() 就了當了
另外,其實還想知道 Application.exit() 和 Me.Dispose 有何分別?有人可以教一下嗎?..

順提留一網 : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2665845&SiteID=1&pageid=1
代碼記一下 :

1
2
3
4
5
6
7
8
9
10
11
12
Private Sub MainForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If MessageBox.Show("Do you want to exit ?", "Tips", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = Windows.Forms.DialogResult.No Then
e.Cancel = True
Else
Me.Dispose(True)
End If
End Sub

' Clicked Exit
Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem1.Click
Me.Close()
End Sub