首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

关于关闭窗口时的有关问题

2012-06-01 
关于关闭窗口时的问题我想实现关闭一个关闭form1这个事件时,出现msgbox,如果选yes就退出程序,如果选no就隐

关于关闭窗口时的问题
我想实现关闭一个关闭form1这个事件时,出现msgbox,如果选yes就退出程序,如果选no就隐藏当前窗口,但是我的程序好像没进入if语句,不论写yes还是no都是退出程序  
 Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  Dim message, title As String
  Dim style As MsgBoxStyle
  Dim response As MsgBoxResult
  message = "你是否退出程序执行?"
  style = MsgBoxStyle.Question Or MsgBoxStyle.YesNo
  title = "msgBox测试"
  response = MsgBox(message, style, title)
  If response = MsgBoxResult.Yes Then
  End
  Else
  Me.hide()
  End If
  End Sub

[解决办法]
如果不想退出,在Form_Closing事件的参数e里,设置e.Cancel=True,表示不关闭窗口。

热点排行