如何做,如果取消保存文件对话框按钮被点击? [英] How to do something if cancel button on save file dialog was clicked?

查看:331
本文介绍了如何做,如果取消保存文件对话框按钮被点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#的WinForms。我有一个保存弹出对话框后,一个消息框,指出它是保存成功。

I am using c# WinForms. I have a save dialog box that pops up and a message box after that that says it was saved successfully.

我刚刚意识到,如果用户点击取消,我的消息框还是来了。

I just realized that if a user clicks cancel, my message box still comes.

我如何知道,当用户点击,当它被取消取消在保存对话框,然后做些什么按钮?

How do i tell when a user clicks the cancel button on a save dialog box and then do something when it is cancelled?

推荐答案

一个保存对话框有DialogResult属性设置为会发生什么。
你的情况:

A save dialog box after closing has the DialogResult property set to what happens. In your case:

if (mySaveDialog.DialogResult == DialogResult.OK) { /* show saved ok */ }

这篇关于如何做,如果取消保存文件对话框按钮被点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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