Solved

Jump to listview1 item by pressing a keyboard letter

Posted on 2004-08-17
7
309 Views
Last Modified: 2010-04-17
I would like to find out if I can jump to specific lines on a listview by pressing the first letter of the text (as you can when using a list).

Specifically, the text is in the subitem(3) area of the listview.

Can someone provide me with a working example. or let me know if it is even possible?
0
Comment
Question by:robbperk
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 6

Expert Comment

by:pillbug22
ID: 11823738
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 11823756
Of course, I was assuming this is for a web page - if it's not, then let us know and we'll work out something else.

For a windows form, you'd want the KeyPress event for the ListBox (or wherever your user is typing the letter)
0
 

Expert Comment

by:Delian
ID: 11824820
Which programming language are you using?
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

Author Comment

by:robbperk
ID: 11824995
Sorry folks.  Should've have mentioned, this is a vb6 app.
0
 

Author Comment

by:robbperk
ID: 11837945
Guess I need to increase the point value.
REMEMBER, this is a VB6 question (my apologise for leaving that out before).

Please help me out.
0
 

Expert Comment

by:much2k3
ID: 11838933
Hi. Am charles

Put a listview on a form and one textbox where you will type the text to search.

Paste the code below. and run the project


Dim ItmX As ListItem
Private Sub Form_Load()
Dim iCount As Long
With ListView1
    .ColumnHeaders.Add , , "Colum1", .Width / 3
    .ColumnHeaders.Add , , "Colum2", .Width / 3
    .ColumnHeaders.Add , , "Colum3", .Width / 3
    .HideSelection = False
    .View = lvwReport
    .FullRowSelect = True
    .GridLines = True
End With
     For iCount = 1 To 100
        Set ItmX = ListView1.ListItems.Add(, , iCount)
             ItmX.SubItems(1) = iCount + 1
             ItmX.SubItems(2) = iCount + 2
    Next iCount
End Sub

Private Sub Text1_Change()
Dim sItemtoFind As String, iCount As Long
 For iCount = 1 To ListView1.ListItems.Count
    Set ItmX = ListView1.ListItems(iCount)
        If LCase(Text1.Text) = LCase(Left(ItmX.SubItems(2), Len(Text1.Text))) Then
            ListView1.SelectedItem = ItmX
            ListView1.SelectedItem.EnsureVisible
        End If
Next iCount

End Sub
0
 

Accepted Solution

by:
much2k3 earned 75 total points
ID: 11840972
Put a listview on a form and one textbox where you will type the text to search.
'//Some corrections to the previous code
Paste the code below. and run the project


Dim ItmX As ListItem
Private Sub Form_Load()
Dim iCount As Long
With ListView1
    .ColumnHeaders.Add , , "Colum1", .Width / 3
    .ColumnHeaders.Add , , "Colum2", .Width / 3
    .ColumnHeaders.Add , , "Colum3", .Width / 3
    .HideSelection = False
    .View = lvwReport
    .FullRowSelect = True
    .GridLines = True
End With
     For iCount = 1 To 100
        Set ItmX = ListView1.ListItems.Add(, , iCount)
             ItmX.SubItems(1) = iCount + 1
             ItmX.SubItems(2) = iCount + 2
    Next iCount
End Sub

Private Sub Text1_Change()
Dim sItemtoFind As String, iCount As Long
 For iCount = 1 To ListView1.ListItems.Count
    Set ItmX = ListView1.ListItems(iCount)
        If LCase(Text1.Text) = LCase(Left(ItmX.SubItems(2), Len(Text1.Text))) Then
            ListView1.SelectedItem = ItmX
            ListView1.SelectedItem.EnsureVisible
            exit for '//To terminate the loop once item is found
        End If
Next iCount

End Sub
0

Featured Post

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!

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

729 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