【问题标题】:How to check if Cancel button or OK button is pressed in InputBox如何检查输入框中是否按下了取消按钮或确定按钮
【发布时间】:2015-04-20 17:39:01
【问题描述】:
string input = Microsoft.VisualBasic.Interaction.InputBox("To change your email, enter it below. The current email on file is " + ParseUser.CurrentUser.Email, "Change Email", "New Email", -1, -1);

鉴于上述代码,我如何检查是否按下了取消按钮或确定按钮?如果用户按下 OK,我想运行一个方法。如果他们按下取消,那么我就不会运行该方法。

检查字符串是否为 0 个字符长是行不通的,因为即使用户开始输入并按下取消,我仍然不希望该方法运行。

【问题讨论】:

标签: c# visual-studio-2013 inputbox


【解决方案1】:

如果检查 0 个字符不足以判断是否单击了取消,那么您需要构建自己的对话框来代替 InputBox。

【讨论】:

【解决方案2】:
var answer = confirm('Are You Sure');
if (answer) {
   //...
} else {
   //...
}


//answer will be true here`enter code here`

【讨论】:

  • 这个问题不是 JavaScript。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-11-25
  • 1970-01-01
  • 2018-01-25
  • 2020-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多