MessageBox的使用YesNoCancel

编程入门 行业动态 更新时间:2024-10-23 04:37:01
本文介绍了MessageBox的使用YesNoCancel - 否放;取消触发同一事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我与 YesNoCancel 按钮的消息框...

I have a message box with the YesNoCancel buttons...

  • pressing 是会做一些动作和关闭应用程序 - 正常工作
  • pressing 否会做什么并关闭应用程序 - (见下文)
  • pressing 取消会做什么,保持应用程序打开 - 。(见下文)
  • Pressing Yes will do some action and close the application - works fine
  • Pressing No will do nothing and close the application - (see below)
  • Pressing Cancel will do nothing and keep the application open - (see below).

我用 DialogResult.No 为否按钮和 DialogResult.Cancel 为取消按钮。但是,pressing其中任何一个触发 DialogResult.Cancel 事件。有什么问题?

I'm using DialogResult.No for the No button and DialogResult.Cancel for the Cancel button. But pressing either of them triggers DialogResult.Cancel event. What's the problem?

推荐答案

这应该很好地工作:

Dim result As Integer = MessageBox.Show("message", "caption", MessageBoxButtons.YesNoCancel) If result = DialogResult.Cancel Then MessageBox.Show("Cancel pressed") ElseIf result = DialogResult.No Then MessageBox.Show("No pressed") ElseIf result = DialogResult.Yes Then MessageBox.Show("Yes pressed") End If

更多推荐

MessageBox的使用YesNoCancel

本文发布于:2023-10-27 00:05:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531737.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MessageBox   YesNoCancel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!