DateTimePicker as ListView sub-item

  • Thread starter Thread starter Jimmy Talbot
  • Start date Start date
J

Jimmy Talbot

Hi,

In my MovieScheduler app, I have a listview with a column of "times"
(actually, TimeSpan's) (see
http://www.dgp.toronto.edu/~jtalbot/moviescheduler -- 2nd screenshot from
the top, showing the list of movies). I want to let the user edit those. So
I put a DateTimePicker whenever the user clicks on that column. That's all
working fine.

My question is, how can I detect that the user clicked "on something else"?
There's lots of other things the user can click on -- tabs, menu items,
scrollbars, etc... I wouldn't want to have to catch each of those other
components' click events... But, the DateTimePicker doesn't seem to have
"lost focus" event...?

Thanks
JT
 
Well, I figured it out on my own. In the unlikely event that someone else
had the same problem, here's what I did.

I set a handler for the DateTimePicker's Leave event. Then, after making the
DateTimePicker visible, I called its Focus() method. Thereafter, everytime
the user clicks outside of the DateTimePicker (i.e., when it loses focus),
then the Leave event is fired.

This is exactly what I wanted. Except I would have called the Leave event
"FocusLost". Leave makes it sound like the mouse cursor left the component.

JT
 
Back
Top