Leave event in a Usercontrol

  • Thread starter Thread starter liups
  • Start date Start date
L

liups

Hi,
I have an array of usercontrols, each of the usercontrol has a label
and a textbox, I want to do some checking when the textbox loses
focus, the code is like this:

Private Sub txtTextBox_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtTextBox.Leave

select case me.tabindex
case 3...
case 5...

but this event won't fire, while "txtTextBox_KeyPress" is working
without problem.
I figured out that I can use the usercontrol's own 'leave' event,
because the label's TabStop is set to false and the textbox's TabStop
is true, so leaving the textbox means leaving the usercontrol, but the
usercontrol is in a control array, the IDE says I cannot use
'withevents' on control array, but this is not a good solution anyway,
I'm trying to do the checking inside the usercontrol.
Thanks for any ideas.
 
Liups,

can't you simple override OnLeave of your UserControl? That should do it,
since it's inherited from UserControl?

Klaus
 
liups said:
Hi,
I have an array of usercontrols, each of the usercontrol has a
label and a textbox, I want to do some checking when the textbox
loses focus, the code is like this:

Private Sub txtTextBox_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtTextBox.Leave

select case me.tabindex
case 3...
case 5...

but this event won't fire, while "txtTextBox_KeyPress" is working
without problem.
I figured out that I can use the usercontrol's own 'leave' event,
because the label's TabStop is set to false and the textbox's
TabStop is true, so leaving the textbox means leaving the
usercontrol, but the usercontrol is in a control array, the IDE says
I cannot use 'withevents' on control array, but this is not a good
solution anyway, I'm trying to do the checking inside the
usercontrol. Thanks for any ideas.

The leave event fires whenever you jump to another control in the *same*
usercontrol. Enter/Leave events are related to the same containercontrol.
Use Lostfocus instead.

Concerning the array: Have a look at the Addhandler statement.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Hi Armin,

I have told OT in the in the dotnet general group that you are good in
things as the object browser (I hope that I am not wrong) and that it could
be wise to ask his question in this newsgroup.

(About what he write , that is not from me)

Cor
 
Back
Top