Solved

Jump to listview1 item by pressing a keyboard letter

Posted on 2004-08-17
7
305 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
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A short article about problems I had with the new location API and permissions in Marshmallow
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

809 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