Form Causesvalidation property
-
Hello, Iam new to c# My Problem is something like this. Create a sample windows application, having 2 textboxes & a command button Set the forms controlbox property to True Write validation event for the 2 textboxes private void txtpassword_Validating(object sender,System.ComponentModel.CancelEventArgs e) if (txtempno.Text=="" | txtpassword.Text=="") { MessageBox.Show("Please Enter User Id and password","Invalid Data",MessageBoxButtons.OKCancel); e.Cancel = true; } while running the application when the user clicks the button1 the focus is still in 1 of the textboxes, the validation event of the textboxes still fire. Same is the case when the user clicks the X button on the control box. i.e validation event is fired and form is not closed Form Causesvalidation property aslo set flase. if i write the code in the Form1_closing event then also the problem is not being solved. This is because the validation event of the textboxes is fired first so the execution never reaches the Form1_closing event. i need to provide this funcationality in my application,How can i do this?
-
Hello, Iam new to c# My Problem is something like this. Create a sample windows application, having 2 textboxes & a command button Set the forms controlbox property to True Write validation event for the 2 textboxes private void txtpassword_Validating(object sender,System.ComponentModel.CancelEventArgs e) if (txtempno.Text=="" | txtpassword.Text=="") { MessageBox.Show("Please Enter User Id and password","Invalid Data",MessageBoxButtons.OKCancel); e.Cancel = true; } while running the application when the user clicks the button1 the focus is still in 1 of the textboxes, the validation event of the textboxes still fire. Same is the case when the user clicks the X button on the control box. i.e validation event is fired and form is not closed Form Causesvalidation property aslo set flase. if i write the code in the Form1_closing event then also the problem is not being solved. This is because the validation event of the textboxes is fired first so the execution never reaches the Form1_closing event. i need to provide this funcationality in my application,How can i do this?