View Full Version : سوال: رویداد FormClosing
viper2009
دوشنبه 13 مهر 1388, 16:12 عصر
این کد در FormClosing کار نمی کنه چرا؟
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If MessageBox.Show(" ", " ", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.RightAlign) = Windows.Forms.DialogResult.Yes Then
Application.Exit()
End If
End Sub
با پاسخ مثبت و منفی فرم بسته می شه؟
alimanam
دوشنبه 13 مهر 1388, 16:30 عصر
با سلام
برای جلوگیری از بسته شدن فرم باید کد زیر رو در رویداد FormClosing وارد کنی .
e.Cancel = True
یا علی
viper2009
دوشنبه 13 مهر 1388, 18:59 عصر
با سلام
برای جلوگیری از بسته شدن فرم باید کد زیر رو در رویداد FormClosing وارد کنی .
e.Cancel = True
یا علی
با این کار دیگه اصلاً فرم با دستورات در رویدادهای دگر هم بسته نمی شود
viper2009
دوشنبه 13 مهر 1388, 19:49 عصر
من می خوام پیغام هم بده مانند شرطی که گذاشتم
sari-1369
دوشنبه 13 مهر 1388, 20:40 عصر
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
If MsgBox("exit ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Application.Exit()
End If
End Sub
viper2009
دوشنبه 13 مهر 1388, 22:33 عصر
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
If MsgBox("exit ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Application.Exit()
End If
End Sub
آیا خودت هم امتحان کردی ؟
واسه من که نشد
yes که می زنیم بازهم دوباره سوال تکرار میشه
alimanam
دوشنبه 13 مهر 1388, 22:44 عصر
با سلام
دوست عزیز فکر کنم منظورت این باشه ؟
sari-1369
سه شنبه 14 مهر 1388, 09:44 صبح
آیا خودت هم امتحان کردی ؟
واسه من که نشد
yes که می زنیم بازهم دوباره سوال تکرار میشه
ببخشید دوست عزیز ، نه خودم تست نکرده بودم .
از این کد استفاده کن ، کاملا سالم و تست شده .
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
If MsgBox("exit ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
End
End If
End Sub
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.