求助:有条件退出

los19870615 2010-06-07 09:31:30
我有个子窗口,点击退出按钮,要判断某个条件,满足后才执行close(),不满足就继续留在子窗口,怎么写代码?
...全文
42 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复

If( MessageBox.Show("是否关闭当前窗体", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK )
{
//执行关闭消息
}
wuyq11 2010-06-07
  • 打赏
  • 举报
回复
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs)
If MessageBox.Show("是否现在关闭窗口", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) <> DialogResult.OK Then
e.Cancel = True
End If
End Sub
los19870615 2010-06-07
  • 打赏
  • 举报
回复
我是新手,我想要的效果是
点击某个button用if判断后,真则执行 Me.Close(),否则弹出一个msgbox提醒一下,然后继续留在该窗口
兔子-顾问 2010-06-07
  • 打赏
  • 举报
回复
贴代码到你的项目中

protected overrides sub OnClosing(System.ComponentModel.CancelEventArgs e)
if true/*替换为你的判断*/ then e.Cancel = true//阻止关闭
base.OnClosing(e);
end sub

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧