all groups > c# > march 2004 >
You're in the

c#

group:

Last control on focus


Last control on focus glvs NO[at]SPAM hotmail-dot-com.no-spam.invalid
3/19/2004 11:42:02 PM
c#: Hi,
I want to know which control the focus was on last. I have several
listview controls on my form and when I click on "Update" button,
depending on where the focus was I want to perform different tasks.

I tried Focused property on each listview control but unfortunately by
the time the button is clicked the focus is no longer on the listview
controls because focus is now on the button control.

Thanks,
Glenn


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
Re: Last control on focus Tim Jarvis
3/20/2004 1:14:55 AM
[quoted text, click to view]

there is probably a better way than this, but quickly of the top of my
head you could write an event handler for the leave event and attach it
to all the form controls and set a flag when the control lose's focus,
the flag would contain the last one. (the flag could be an enumerated
type, which you then switch from)

A bit of a sledgehammer approach, but could be a plan B if you don't
find a better way.

Re: Last control on focus Vanessa
3/20/2004 1:20:17 PM
There is a 'lostFocus' event he could use to do what you say.


[quoted text, click to view]

Re: Last control on focus Andrija
3/20/2004 1:24:01 PM
use same onfocus event handler for all listviews, and when any of them gets
focus, store a
value (listview name or whatever) into a variable. when updating, use switch
statement to update appropriate listview.
Even easier is to make an array of controls (ListView[] myListViews=new
ListView[x])

AddThis Social Bookmark Button