Last control on focus

  • Thread starter Thread starter glerner
  • Start date Start date
G

glerner

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
 
glerner said:
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



----------------------------------------------------------

----------------------------------------------------------
color]

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.

Rgds Tim.
 
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])
 
Back
Top