在消息框中的按钮的事件处理程序 [英] Event handlers on Message box buttons

查看:124
本文介绍了在消息框中的按钮的事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WinForm aaplication。输入时,在那里所有领域有一个保存按钮。
。在保存按钮,一个消息框出现记录保存成功的点击。 MessageBox中有2个按钮'是'和'不'。如果是则记录应保存所有窗体上的字段应该被清除,如果单击没有所有的字段应该没有得到保存记录在表格上被清除。

i have a winform aaplication. where when all fields are entered there is a save button. On the click of save button a messagebox appears record saved successfully. The messagebox has 2 buttons 'yes' and 'no'. if yes then the record should be saved and all the fields on the form should be cleared and if no is clicked the all the fields should be cleared on the form without the record getting saved.

推荐答案

MessageBox类的Show方法返回的DialogResult:

The Show method of the MessageBox class returns a DialogResult:

DialogResult result = MessageBox.Show("text", "caption", MessageBoxButtons.YesNo);
if(result == DialogResult.Yes){
   //yes...
}
else if(result == DialogResult.No){
   //no...
}

这篇关于在消息框中的按钮的事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆