How to get control of selected component.
-
Hi All, Here i develop a C# Application, in that App. I've 3 Textboxes and 2 Buttons, Default cursor set on TextBox1 and check some condition on TextBox1 Leave. But the problem is that after starting App. I wish to close that App. through Exit Button, but at that time cursor inside TextBox1 so it execute OnLeave function 1st and then I've to again click on Exit button, But i want when I clike on Exit Button in that case OnLeave function will not execute. How it is posible if any one know plz reply. Welcome any tips... Thanx & Regards SMK
-
Hi All, Here i develop a C# Application, in that App. I've 3 Textboxes and 2 Buttons, Default cursor set on TextBox1 and check some condition on TextBox1 Leave. But the problem is that after starting App. I wish to close that App. through Exit Button, but at that time cursor inside TextBox1 so it execute OnLeave function 1st and then I've to again click on Exit button, But i want when I clike on Exit Button in that case OnLeave function will not execute. How it is posible if any one know plz reply. Welcome any tips... Thanx & Regards SMK
Create a flag and make it false when the user clicks the exit button. In the onleave function, first check if the flag is true or not.
Regards, Arun Kumar.A
-
Create a flag and make it false when the user clicks the exit button. In the onleave function, first check if the flag is true or not.
Regards, Arun Kumar.A
Hi, Thanx for ur reply, But my pointer is already in TextBox1 and when I click on Exit button at that time OnLeave event is fired so its not posible to set a flag on exit button in my view I've to check that component(Exit Button)at OnLeave Function. Thanx & Regrsds SMK :doh:
-
Hi, Thanx for ur reply, But my pointer is already in TextBox1 and when I click on Exit button at that time OnLeave event is fired so its not posible to set a flag on exit button in my view I've to check that component(Exit Button)at OnLeave Function. Thanx & Regrsds SMK :doh:
As U have only 5 controls in Ur form, better try this: Create a member as follows: TextBox LastBox; For the OnLeave event of 3 textboxes,write like this:
Text1_OnLeave()
{
LastBox=TextBox1;//Similar assignment in the other 2 textboxes.
}For the OnLeave event of other controls,assign null to the member "LastBox". Create a function as follows: =============================
Validate()
{
if(LastText==TextBox1)
{
Code to validate Textbox1.
}
else if(LastText==TextBox2)
{
Code to validate Textbox2.
}
else if(LastText==TextBox3)
{
Code to validate Textbox3.
}
}Call the "Validate" function in the OnEnter event of all the controls, except ExitButton. If U R not able to find a better solution, use this.
Regards, Arun Kumar.A
-
Hi All, Here i develop a C# Application, in that App. I've 3 Textboxes and 2 Buttons, Default cursor set on TextBox1 and check some condition on TextBox1 Leave. But the problem is that after starting App. I wish to close that App. through Exit Button, but at that time cursor inside TextBox1 so it execute OnLeave function 1st and then I've to again click on Exit button, But i want when I clike on Exit Button in that case OnLeave function will not execute. How it is posible if any one know plz reply. Welcome any tips... Thanx & Regards SMK
- Don't check string.IsNullOrEmoty condition "if it is not necessary (acceptable for values which may be left empty)" which is "I think" true for your TextBox1 with Default cursor OR 2) Don't set default cursor on your TextBox1 when the parent Form is activated (Shown, Selected...) OR 3) update a text changed flag to true in TextBox.TextChanged event and use: if(_boolTextChanged == true) { Validate(); // write your validation code here } else { return; // The user hasn't done anything, why make him/her crazy, DON'T validate anything!!! } 4) I prefer validating everything in one function when the user is finished with all modifications and presses for example the Submit Button which does not break down the nerve system of the user hearing a BEEP sound or ToolTip warning if the validation fails for the control he/she is currently modifying.