Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Key press event

Posted on 2002-07-23
10
Medium Priority
?
275 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
Technology Partners: 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

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!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

610 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