Solved

Key press event

Posted on 2002-07-23
10
269 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
  • 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
 
LVL 4

Accepted Solution

by:
gencross earned 25 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Computer crashes, following error message in event manager 5 138
VBS file using code from 2nd file (txt or vbs) 4 31
Best way to parse out a json string in VB6? 10 111
vbModal 12 34
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now