Hi, I have a form that has many text boxes and two buttons are canceled and OK These buttons accept button properties in the form And have been assigned to cancel. The problem is that I have to validate all the texts recorded in the text box
I want the user to click the OK button (which accepts the button). So I wrote a function which is reponsible for verification and I click the user OK button in the fire if the problem is that I can not close the form even if the verification function return is false. This is due to the fact that I have accepted acceptance of my fine button. Is there any way to stop the form from failing verification without removing acceptance properties?
We use this work solution (and it is compiled from other answers).
To stop the bus, set the DialogResult
to None
to close the form.
// form init, auto-generated code (this is the case as described) Private Zero InitializeComponent () {// .... this.AcceptButton = btnOk; This.btnOk.DialogResult = DialogResult.OK; // ....} // Event Handlers Private Zero BT.NOcal (Object Sender, EventAgages E) {If (! (Valid!)) This.DialogResult = DialogResult.None; } Private Zero form_formcling (Object Sender, FormClosingEventArgs e) {if (this.DialogResult == DialogResult.None) e.Cancel = true; }
Comments
Post a Comment