首页 新闻 会员 周边

VS2005 C# 中怎样取得自定义对话框 ymPrompt.confirmInfo()的返回值?

0
悬赏园豆:15 [已关闭问题]

想用它判断是否进行删除操作,如果删除,就执行删除代码,

如果不删除,就什么也不做。

非常感谢

cytreasure_20110904的主页 cytreasure_20110904 | 菜鸟二级 | 园豆:395
提问于:2009-08-29 13:44
< >
分享
其他回答(1)
0

c#中需要使用 dialogresult 类型的变量,从messagebox.show()方法接受消息对话框的返回值。至于messagebox.show()的返回值是 yes 、no, ok还是cancel,那需要自己在show()方法中对它可以显示的选择按钮进行设置。以下示例代码可以参考:


// initializes the variables to pass to the messagebox.show method.

string message = "you did not enter a server name. cancel this operation?";
string caption = "no server name specified";
messageboxbuttons buttons
= messageboxbuttons.yesno;
dialogresult result;

// displays the messagebox.

result
= messagebox.show(this, message, caption, buttons,
messageboxicon.question, messageboxdefaultbutton.button1,
messageboxoptions.rightalign);

if(result == dialogresult.yes)
{
//do your action here.
}
邀月 | 园豆:25475 (高人七级) | 2009-08-29 13:51
0

如果是在网页上应用的话,你可以向删除按钮注册一个事件 return confirm('你确实要删除吗?')

伽马科技.攻城师 | 园豆:1303 (小虾三级) | 2009-08-29 14:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册