Activate Event Equivilent for UserControl?

C

CGatto

Hi,

I have Windows Form with several User Controls embedded within. Only one
user control is visible at any one time. The user moves through the various
user controls by clicking Previous and Next buttons. What I want to happen
is for the individual user controls to have the ability to set focus to a
specific textbox control when the user control becomes active. Normally I
would handle this sort of thing via a form's activate event, but user
controls do not have this equivalent I've tried the GotFocus and Enter
events as well but neither fires independently simply when the user control
becomes the form's focus.

Right now I have the textbox focus working - but only through calling it via
the parent form (the parent form causes the user control to come to the
forefront, then sets the focus). But I'd rather have the logic self
contained within the user control. Is there some sort of Activate event
equivilent for user controls?

Thanks
 
A

Armin Zingler

CGatto said:
Hi,

I have Windows Form with several User Controls embedded within. Only
one user control is visible at any one time. The user moves
through the various user controls by clicking Previous and Next
buttons. What I want to happen is for the individual user controls
to have the ability to set focus to a specific textbox control when
the user control becomes active. Normally I would handle this sort
of thing via a form's activate event, but user controls do not have
this equivalent I've tried the GotFocus and Enter events as well
but neither fires independently simply when the user control becomes
the form's focus.

Right now I have the textbox focus working - but only through
calling it via the parent form (the parent form causes the user
control to come to the forefront, then sets the focus). But I'd
rather have the logic self contained within the user control. Is
there some sort of Activate event equivilent for user controls?

Good question for the appropriate m.p.d.framework.* group (because it's
not a VB language specific issue). Nevertheless, maybe I've missed
something, but is there a reason why you don't set the Tabindex property
of the control to get the focus to zero? When showing a Usercontrol (in
the button's click event), just call TheUC.Focus in addition (what you
have to do anyway).

I would not write the UC in that way that it automatically claims the
focus when becoming visible because that should be done by the container
(Form) if wanted. I read your question that you only don't want to set
the focus to the first control inside the UC, but that's automatically
done by setting Tabindex=0.


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top