【发布时间】:2013-12-28 10:22:03
【问题描述】:
我会尽力解释。
我正在使用一个类 InputBox 并使用一个方法 shutownTime
class InputBox
{
public static DialogResult shutdownTime(string title, string promptText, ref string value)
{
我正在返回值
DialogResult dialogResult = form.ShowDialog();
return dialogResult;
在另一种方法中,我将值从另一个类传递给它。
string title2 = "Shutdown Timer";
string promptText = "How long would you like to delay the shutdown in minutes?";
string value = "0";
InputBox.shutdownTime(title2, promptText, ref value);
一切正常,但是当我按下 OK 按钮时,如果我按下 shutdownTime 方法中的 Cancel 按钮,调试会显示返回值为 Cancel
//shutdownTime()
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
我无法得到的是,如果我按取消,我如何在使用后检查该值
InputBox.shutdownTime(title2, promptText, ref value);
因为我可以按确定或取消,它只是继续代码。
希望我说得通,谢谢
【问题讨论】:
标签: c# dialogresult