• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

Jump to listview1 item by pressing a keyboard letter

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
robbperk
Asked:
robbperk
  • 2
  • 2
  • 2
  • +1
1 Solution
 
pillbug22Commented:
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
 
DelianCommented:
Which programming language are you using?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
robbperkAuthor Commented:
Sorry folks.  Should've have mentioned, this is a vb6 app.
0
 
robbperkAuthor Commented:
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
 
much2k3Commented:
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
 
much2k3Commented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now