• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Key press event

I have a List view .
And i want a simulate key press (for example ,up arrow)

List view  have a event :
ItemClick(ByVal Item As MSComctlLib.ListItem)
How can I use it?
0
Vlad77
Asked:
Vlad77
  • 5
  • 4
1 Solution
 
gencrossCommented:
To simulate a keypress use Sendkeys

SendKeys "{UP}"

When an item is checked or unchecked in a listview this event is fired.  Use it this way...

ItemClick(ByVal Item As MSComctlLib.ListItem)
    Msgbox "The item tag is " & Item.Tag
End Sub
0
 
Richie_SimonettiIT OperationsCommented:
In which one of them?
0
 
Vlad77Author Commented:
I didn't understand where i am writing :
  SendKeys "{UP}"

What I want is when I click on command button ,she will
sellect next row in the List View .
How can I do this ?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
gencrossCommented:
Something like this should work...

Private Sub Command1_Click()
   
    lv.ListItems(lv.SelectedItem.Index + 1).Selected = True
   
End Sub
0
 
gencrossCommented:
NOTE: If you are on the last item then you will probably get an error so you will want to check before hand.
0
 
Richie_SimonettiIT OperationsCommented:
But if you do that, item is not selected anymore!
0
 
Richie_SimonettiIT OperationsCommented:
you have to add lv.setfocus after that code.
0
 
gencrossCommented:
I assumed that Vlad77 wanted to scroll through the listview by clicking a button.

I have not tested this, but perhaps setting the MultiSelect property to True would leave the previous items selected if that is what Vlad wants.

I guess I'm not really sure what (he/she) wants :)
0
 
gencrossCommented:
I see what you are saying...The listview loses focus.  

Yea, SetFocus will fix that.

(See what happens when you just merrily type away in the EE text box and not test the code?)
0
 
Richie_SimonettiIT OperationsCommented:
"(See what happens when you just merrily type away in the EE text box and not test the code?) "
yeah, all the time myself!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now