Solved

Jump to listview1 item by pressing a keyboard letter

Posted on 2004-08-17
7
303 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 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