Focus of constituent control inside custom control 
Author Message
 Focus of constituent control inside custom control

Hi all,

There is one textbox control and other controls inside my
custom control.  when the custom control lost focus on
form, I found that the textbox control still has focus
indside the custom control.  So when the custom control
got focus again, the textbox will not run GotFocus or
Enter event (since it didn't lose focus before)!

Is there any way to make the textbox control lost focus
once the custom control lost focus?  I need it because
there is some tailor-made routine when the textbox
control got focus.

I've tried set Me.ActiveControl = Nothing inside custom
control when the focus is going to leave (in Leave
event).  However, this statement makes the custom control
got focus again so the focus keeps in custom control.

Hope you can understand my problem and thanks for your
help!

Regards,
James



Tue, 31 May 2005 16:06:49 GMT  
 Focus of constituent control inside custom control
Hi James,

Can you post the code you have in your UserControl1_Leave event?  I tried
setting Me.ActiveControl=Nothing and that makes the textbox lose focus and
the control doesn't seem to get focus again.  Do you have any other events
that could be interfering?

Thanks,
Eric Gruber
VB.Net

--
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
> Hi all,

> There is one textbox control and other controls inside my
> custom control.  when the custom control lost focus on
> form, I found that the textbox control still has focus
> indside the custom control.  So when the custom control
> got focus again, the textbox will not run GotFocus or
> Enter event (since it didn't lose focus before)!

> Is there any way to make the textbox control lost focus
> once the custom control lost focus?  I need it because
> there is some tailor-made routine when the textbox
> control got focus.

> I've tried set Me.ActiveControl = Nothing inside custom
> control when the focus is going to leave (in Leave
> event).  However, this statement makes the custom control
> got focus again so the focus keeps in custom control.

> Hope you can understand my problem and thanks for your
> help!

> Regards,
> James



Sat, 04 Jun 2005 05:10:40 GMT  
 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.

  TestBox.vb
3K Download


Sat, 04 Jun 2005 12:40:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Handling the focus in a custom control inside a datagrid cell

2. Handling the focus in a custom control inside a datagrid cell

3. ActiveX - focus problem with constituent controls

4. Cannot shift focus from custom control to other control

5. UpDown-Control as a constituent control for a UserControl not working

6. Expose array properties of a constituent control to the ActiveX control

7. control focus inside web page

8. Any ways to make focus on Label control like focus in button control

9. Custom Control: Container inside container...

10. Custom Control: Container inside container...

11. Transparent color in constituent control

12. Exposing Read-Only Properties of Constituent Controls

 

 
Powered by phpBB® Forum Software