CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011
    Posts
    5

    Want to use a listview instead of listbox

    I used the given below codes to search the items of listbox and scroll the items of listbox by a textbox:-

    Code:
    Private Declare Function SendMessageByString _
                             Lib "user32" _
                             Alias "SendMessageA" _
                             (ByVal hwnd As Long, _
                              ByVal wMsg As Long, _
                              ByVal wParam As Long, _
                              ByVal lParam As String) _
    As Long
    
    Private Const LB_SELECTSTRING = &H18C
    
    Private Sub Text6_Change()
    Dim lngEntryNum     As Long
        Dim strTextToFind   As String
        
        strTextToFind = Text6.Text
        
        lngEntryNum = SendMessageByString(List1.hwnd, _
                                          LB_SELECTSTRING, _
                                          0, _
                                          strTextToFind)
    End Sub
    
    Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim i As Integer
    i = List1.ListIndex
    If KeyCode = vbKeyDown Then
    i = i + 1
    If i > List1.ListCount - 1 Then
    i = 0
    End If
    List1.ListIndex = i
    End If
    End Sub
    Now, I want to use a listview instead of the listbox. Please help me how to do the same for a listview.

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Want to use a listview instead of listbox

    You can try if ListView also reacts on LB_SELECTSTRING message.
    But possibly it has individual messages like LV_FINDINFOW. Im not quite sure. So if you got some time, then google for LV_FIND* to get more info.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured