Solved

Key press event

Posted on 2002-07-23
10
268 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 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

20 Experts available now in Live!

Get 1:1 Help Now