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
ItemActivate event in a ListView controlHow to determine what raised the event?
Page 1 of 1
5 Replies - 6640 Views - Last Post: 26 March 2009 - 08:46 AM
Replies To: ItemActivate event in a ListView control
#2
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
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
#3
Re: ItemActivate event in a ListView control
Posted 26 March 2009 - 06:56 AM
ixios, 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
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
#4
Re: ItemActivate event in a ListView control
Posted 26 March 2009 - 08:34 AM
Did the KeyDown Event work for you?
#5
Re: ItemActivate event in a ListView control
Posted 26 March 2009 - 08:40 AM
#6
Re: ItemActivate event in a ListView control
Posted 26 March 2009 - 08:46 AM
Excellent! I'm glad you got it!

Page 1 of 1