ItemActivate event in a ListView control

How to determine what raised the event?

Page 1 of 1

5 Replies - 5146 Views - Last Post: 26 March 2009 - 08:46 AM Rate Topic: -----

#1 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

ItemActivate event in a ListView control

Post icon  Posted 26 March 2009 - 05:19 AM

I'm writing some code in c# for a mobile device.

I have a list view that raises the ItemActivate event on a double click or by the user selecting an item using the cursor keys and pressing Enter.

This may be a silly question, but how can I determine whether it was the double click or the Enter/Return key pressed that raises the event? The EventArgs doesn't seem to have any concept of keypresses. I tried to enable an event handler for the KeyPress, but it raises the ItemActivate event first.

I'm fairly new to C# and .Net so excuse me if this is a little trivial.

Thanks in advance.

Mark

Is This A Good Question/Topic? 0
  • +

Replies To: ItemActivate event in a ListView control

#2 ixios  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 34
  • Joined: 01-March 09

Re: ItemActivate event in a ListView control

Posted 26 March 2009 - 05:48 AM

Hi there,


Would the listView Capture property work for you? (e.g. listView1.Capture). It's a bool that tells you whether the listView Control has captured the mouse. I ran a quick test... when I clicked an item, it is TRUE, when I pressed Enter to select the item, it is FALSE...


Hope this helps..


Paul
Was This Post Helpful? 0
  • +
  • -

#3 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: ItemActivate event in a ListView control

Posted 26 March 2009 - 06:56 AM

View Postixios, on 26 Mar, 2009 - 04:48 AM, said:

Hi there,


Would the listView Capture property work for you? (e.g. listView1.Capture). It's a bool that tells you whether the listView Control has captured the mouse. I ran a quick test... when I clicked an item, it is TRUE, when I pressed Enter to select the item, it is FALSE...


Hope this helps..


Paul


Hi Paul,

Thanks for the reply.

I tried this suggestion and it appears that when double clicking on the device screen (i.e. touchscreen device), it isn't setting the variable to indicate it's mouse activity (which I though it might do) as opposed to keyboard, in both instances it returns false.

Any other suggestions?

Mark

[EDIT]

I feel really stupid now....I had tried in the past using the Keypress event which didn't work, what I should have used was the KeyDown event, which does fire before the ItemActivate! :(

This post has been edited by maj3091: 26 March 2009 - 07:40 AM

Was This Post Helpful? 0
  • +
  • -

#4 ixios  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 34
  • Joined: 01-March 09

Re: ItemActivate event in a ListView control

Posted 26 March 2009 - 08:34 AM

Did the KeyDown Event work for you?
Was This Post Helpful? 0
  • +
  • -

#5 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: ItemActivate event in a ListView control

Posted 26 March 2009 - 08:40 AM

View Postixios, on 26 Mar, 2009 - 07:34 AM, said:

Did the KeyDown Event work for you?


Yeah, the KeyDown event works a treat.....silly mistake on my part really.

Nevermind - you live and learn. :)
Was This Post Helpful? 0
  • +
  • -

#6 ixios  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 34
  • Joined: 01-March 09

Re: ItemActivate event in a ListView control

Posted 26 March 2009 - 08:46 AM

Excellent! I'm glad you got it! :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1