?
Solved

Key press event

Posted on 2002-07-23
10
Medium Priority
?
274 Views
Last Modified: 2010-05-02
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
Comment
Question by:Vlad77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 7172240
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7172309
In which one of them?
0
 

Author Comment

by:Vlad77
ID: 7172583
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
gencross earned 100 total points
ID: 7172642
Something like this should work...

Private Sub Command1_Click()
   
    lv.ListItems(lv.SelectedItem.Index + 1).Selected = True
   
End Sub
0
 
LVL 4

Expert Comment

by:gencross
ID: 7172643
NOTE: If you are on the last item then you will probably get an error so you will want to check before hand.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7172671
But if you do that, item is not selected anymore!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7172673
you have to add lv.setfocus after that code.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7172677
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
 
LVL 4

Expert Comment

by:gencross
ID: 7172684
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7172756
"(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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question