取消对话框关闭确定/取消按钮单击 [英] Cancel DialogBox Close on Ok/Cancel Button Click

查看:186
本文介绍了取消对话框关闭确定/取消按钮单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好!!!!


我有一个表单(frmDialogForm),我从父表单(frmParent)打开。我打开frmDialogForm作为对话框,用户输入一些信息。用户单击具有DialogResult.OK的保存按钮。



当您单击保存按钮时,我想要做的是验证信息,如果用户输入的信息无效,那么frmDialogForm不会关闭。





Thanx ...

Good morning all!!!

I have a form (frmDialogForm) that I''m opening from a parent form (frmParent). I''m open frmDialogForm as a dialogbox the the user inputs some information. The the user clicks the "Save" button which has DialogResult.OK.

What I want to do is validated the information when the you clicks the Save button and if the information inputted by the user is not valid then frmDialogForm does not close.


Thanx...

推荐答案

在你的frmDialogForm中订阅FormClosing事件并设置''FormClosingEventArgs''值,说e.Cancel = true;这不会关闭你的表单。



这里你可以做什么在frmDialogForm中保留一个布尔成员变量,并根据你的验证设置这个值为true / false以保持表格打开。
Subscribe the FormClosing event inside your frmDialogForm and set ''FormClosingEventArgs'' value say e.Cancel = true; which does not close your form.

what you can do here keep a boolean member variable inside the frmDialogForm and set this value true/false based on your validation to keep the form open.


这篇关于取消对话框关闭确定/取消按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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