在Windows窗体中返回Messgebox.Show的值 [英] Return value for Messgebox.Show in windows Forms

查看:83
本文介绍了在Windows窗体中返回Messgebox.Show的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts,



我有一个Windows窗体应用程序。您可以从列表框或Datagridview中删除的位置。我想在删除之前询问用户是否确定要删除。

这是我的MEssage框。



Hello Experts,

I have a windows forms application. Where you can delete from the Listbox or Datagridview. I wanted to ask before deleting if user is sure about the deletion.
That's my MEssage box.

MessageBox.Show("Are You sure to Delete the selected Item? It will clear out the selection from Grids ", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)





现在如果他点击确定我想要删除。如果他点击取消我想保持不变。如何获取此消息框的返回值?我使用过Web表单,我使用Jquery来了解返回的Dialog的值。但是我不知道如何在Windows窗体中获得价值。



请帮助我理解所需的内容。



Now if he clicks on OK I want to Delete. If he clicks on Cancel I want to stay the same . How do I get the return value of this message box? I have worked with Web forms where I used Jquery to know the value of Dialog returned. But I don't know how to get the value in Windows forms.

Please help me in understanding the desired.

推荐答案

MessageBox.Show(..)返回 DialogResult [ ^ ] -enum告诉你点击了哪个按钮。



上面的链接显示了值Enum并提供样本。

另一个很好的例子: http://www.dotnetperls.com/ messagebox-show [ ^ ]
MessageBox.Show(..) returns a DialogResult[^]-enum that tells you which button was clicked.

The link above shows the values of the Enum and provides a sample.
Another good example: http://www.dotnetperls.com/messagebox-show[^]


这篇关于在Windows窗体中返回Messgebox.Show的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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