
Focus of constituent control inside custom control
Hi Eric,
Thanks for your reply! I've tried many different ways to
solve my problem but all were failed even I changed my
routine to very very simple testing code.
Attached is simple version of my custom control. There's
only one textbox inside now. What I want to do is:
a) When the custom control got focus, change textbox's
color.
b) When the custom control lost focus, change back
textbox's color.
c) Of course, in my real project, many other things to do
when getting focus and lossing focus.
You'll find that I've created a variable called
intEnterCounter which will be accumulated within
clsTestBox_Enter event. In clsTestBox_Leave event, I
keep track intEnterCounter just before and after calling
Me.ActiveControl = Nothing. The result I got is:
a) If I click other control on the parent form, the
counter is same before and after call Me.ActiveControl =
Nothing. That means no re-entry occurs. The color
changes as expected.
b) If I press [Tab] or [Shift]-[Tab] within my custom
control, the counter after calling Me.ActiveControl =
Nothing is greater than the counter before calling. That
means re-entry occurs. The color does't change and focus
is still inside my custom control. That's exact the
problem I'm facing now.
I hope you can understand my long explaination and point
out what I've done wrong.
Thanks for your help again!
Regards,
James Wong
Quote:
>-----Original Message-----
>Hi James,
>Can you post the code you have in your
UserControl1_Leave event? I tried
Quote:
>setting Me.ActiveControl=Nothing and that makes the
textbox lose focus and
Quote:
>the control doesn't seem to get focus again. Do you
have any other events
Quote:
>that could be interfering?
>Thanks,
>Eric Gruber
>VB.Net
>--
>This posting is provided "AS IS" with no warranties, and
confers no rights.