本文介绍了C#:不使用按钮时如何发送“确定”或“取消”对话框的返回消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

C#:不使用按钮时如何发送确定或取消对话框的返回消息?

C#: How do you send OK or Cancel return messages of dialogs when not using buttons?

在文本框如下的情况下,如何返回确定消息?会在用户按下Enter键时继续执行,并在用户按下Ctrl + Q键时发送取消消息吗?

How would you return the OK message in the condition of a textbox that will proceed when the user presses Enter, and will send Cancel when the user presses Ctrl+Q?

忽略:
解决方案-this.dialogresult = dialogresult.ok或dialogresult.cancel。

Disregard:solution- this.dialogresult = dialogresult.ok or dialogresult.cancel.

推荐答案

设置表单的 DialogResult

this.DialogResult = DialogResult.OK;
this.Close();

这将导致任何使用 ShowDialog()打开此表单的打开器以获得给定的 DialogResult 作为结果。

This would cause any opener that opened this form with ShowDialog() to get the given DialogResult as the result.

这篇关于C#:不使用按钮时如何发送“确定”或“取消”对话框的返回消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 23:16