|
-
Jan 4th, 2013, 05:51 PM
#1
Thread Starter
Member
Leave event not triggered when access key activated for button
I have a textbox on a form. I have a procedure to check the validity of entry when the LEAVE event for that textbox takes place. There is also a button to exit the form which has an access key. if I click on the button the LEAVE event is triggered, but if I use the ALT-character to "click" the button the LEAVE event for the textbox is not triggered. How can I do it for the latter situation?
-
Jan 4th, 2013, 05:58 PM
#2
Re: Leave event not triggered when access key activated for button
Why aren't you doing this on the button click event making it irrelevant how the button is 'pressed'?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Jan 4th, 2013, 06:01 PM
#3
Thread Starter
Member
Re: Leave event not triggered when access key activated for button
Because I actually have dozens of textboxes, each with its own validity-checking routine, and each must checked when that box is left rather than all at once at the end
-
Jan 4th, 2013, 06:44 PM
#4
Re: Leave event not triggered when access key activated for button
Not sure that this is really the best event for validation (that's what the validation events are for!) but the easiest way to force a leave is ...
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Button1.Focus()
End Sub
... which will work however the click is invoked.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Jan 4th, 2013, 07:05 PM
#5
Re: Leave event not triggered when access key activated for button
You shouldn't be using the Leave event for validation. As dunfiddlin says, that's what the validation events are for. You should be handling the Validating event, not Leave. When you use the accelerator key to "click" a Button it does not receive focus, so of course the Leave event of the TextBox isn't raised, because focus doesn't leave the TextBox. Both the Validating and Validated events will be raised though, because they are designed to be used for validation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|