473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Activate Event Equivilent for UserControl?

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

Jun 27 '08 #1
2 8650
CGatto wrote:
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.
Did you try the EnterFocus event? It seems to work for me...
Jun 27 '08 #2
"CGatto" <cg****@pleaseremoveme.gnb.caschrieb
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

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jralford | last post by:
Hi, Another question from a C# newbie: I have a usercontrol class that includes a customized control. Now, if I create an instance of the class, and click on it, a click event is raised for the...
2
by: Tim_Mac | last post by:
hi, i have an aspx page which dynamically loads a user control and adds it to a placeholder. the control is recreated and added to the placeholder for postbacks as well. the user control...
1
by: Lin | last post by:
Hi All, I have a UserControl and in the UserControl I have a few controls (textbox buttons ect.) and I want to know how can I fire the "onchange" event (of the usercontrol) when the textbox in...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
5
by: seal | last post by:
OK, I am trying to fire an event from a usercontrol that tells the page when a checkbox was clicked. Here is the control and when I try and wire up the page to catch the event, my event is not...
2
by: Franky | last post by:
Threre is a Form containing a usercontrol In the form's Load event it references a usercontrol property, say, zz The first showdialog(formx) causes 1 usercontrol_load event 2 form_load event...
7
by: Andrus | last post by:
I have UserControls in MDI child forms containing TextBoxes and other controls. When user re-activates form, I need that Control which was last activated is activated again. Currently *first*...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.