Kanimozhi Shivakumar

Kanimozhi Shivakumar

  • NA
  • 293
  • 154.6k

Validating Event is firing when Close button(Form "Button")

Jul 19 2018 6:14 AM
Hi ,
 
In my project , I have one MDI Parent form and n number of child forms..I can open multiple child forms on my screen. 
 
I have Form1 and it has two text boxes which is mandatory to enter. When the text box value is not entered , the cursor should not allow to focus on next control..So I have written validating event (as mentioned below) :
 
  1. private void txtCod_Validating(object sender, CancelEventArgs e)  
  2.         {  
  3.             try  
  4.             {  
  5.                 if (clsMdiForm.blnBlankCheck(txtCode.Text, false"CODE"))  
  6.                 {  
  7.                     e.Cancel = true;  
  8.                 }  
  9.                 else  
  10.                 {  
  11.                     e.Cancel = blnChkUniqueLoc(0);  
  12.                 }  
  13.             }  
  14.             catch (Exception ex)  
  15.             {  
  16.                 clsMdiForm.writeErrorLog(ex.HResult.ToString(), ex.Message, "txtCod_Validating""frmMaLocation");  
  17.             }  
  18.         }  
I opened the form1 and cursor is focused in textbox1 which contains empty value. I am trying to close my form1 / trying to open different form  but it is going to form1 textbox1 validating event..
 
As per my requirement it should allow to close the form and allow to open some other forms also..
I am not getting the solution so I keep the bugs in deferred status..Please some one help me to sort out this issue. 
 
 

Answers (1)