Event Ordering

robh

Member
Licensed User
Longtime User
I am trying to achive the following:

User enters data in Edittext box, on FocusChanged event I am running some validation code when focus has been lost(HasFocus = False).

User clicks button to Add data, problem is button_click event code is running, adding the data then causing the EditText_Focus changed validation event to fire.

The above is causing me all manner of problems, what I want to achieve is, focus on edittext, user clicks a button, button causes edittext focuschanged event to run and then the button_click event.

Can anybody give me a clue? :)
 

mc73

Well-Known Member
Licensed User
Longtime User
Why not simply calling the textBox validation sub inside button_click?
 
Upvote 0

robh

Member
Licensed User
Longtime User
Why not simply calling the textBox validation sub inside button_click?

I simplified the example somewhat, there are other text boxes involved on this screen and as each one is entered and tabbed through, there are several on screen values being calculated on the fly. The text box is only clicked when the user is happy with all of the data, I still need to retain the validation on the leaving of each textbox in order to calculate the values on the fly, there is no set order as to which textbox the user has to poulate first, for example I have a 'Qty' textbox and a 'Unit Price' text box.

As a catch all I will put the validation behind click of the button but the problem still exists and I'm struggling to find a workaround at the moment.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
At the beginning of the button click event, place a flag, flagbuttonclick=true. At the beginning of the focuschange sub of the text box, place an if flagbuttonclick=true then return else perform your checks here.
Declare the flag at your sub globals and don't forget to call any validation routine from your button click if needed.
 
Upvote 0
Top