Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Leave/Enter events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Egil Winther - 20 Apr 2005 10:26 GMT
Hi All,

Is there a way to find out, on the leave-event, which control that is about
to receive focus?

Rgds
Egil Winther
ShipNet AS
Marvin Varela - 20 Apr 2005 22:51 GMT
You could use something like:

private Control ctlLeft = null;
private Control ctlEntered = null;
private void Control_Leave(object sender, System.EventArgs e) {
   ctlLeft = (Control)sender;
}
private void Control_Enter(object sender, System.EventArgs e) {
   ctlEntered = (Control)sender;
}
And then assign this method to all the enter and leave events on your form
(selecting them all and in the properties window selecting it from the
combobox)

This way you will always have a pointer to the recently left and recently
entered control.

You have to consider that the Leave event runs even before the other control
takes the focus so what you need to do you should do it in the Enter event
knowing which control you left. This way you can go back to that control and
do anything else you want with it.

Also remember you can add as many event handlers as you want to the Enter
event if you do it by code, so even if you assign this event handler to all
your control you can still assign another handler to do whatever you need to
do for each specific control. You just need to use the following line of
code to do the assignment:

this.textBox1.Leave += new System.EventHandler(this.Control_Leave);
this.textBox1.Enter += new System.EventHandler(this.Control_Enter);

Hope this works.

> Hi All,
>
[quoted text clipped - 4 lines]
> Egil Winther
> ShipNet AS

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.