Results 1 to 3 of 3

Thread: Listbox Problem

  1. #1

    Thread Starter
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158

    Unhappy

    I wrote some code to add file names to a list box for program i'm working on, there are 2 colums one for the file name one for the file's path, similar to vb open project(recent tab) dialog box.

    When I add a item and set it's selected property to tru it doesn't show up hight lighted. The only way I can highlight a item is to select it via mouse.

    How can I slected the newly added property, so that it actually shows up selected to the user.

    Please help...Thanks!!!

  2. #2
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Sydney Australia
    Posts
    476
    It should work

    Try setting fullrowselect to true

    He's my code that worked

    Private Sub cmdFind_Click()
    m_strCurrentProcedure = "cmdFind_Click"
    On Error GoTo ErrorHandler
    Dim intIndex As Integer
    Dim intTotalItems As Integer
    Dim ltiItem As ListItem

    If m_strSearchKey = "Account" Then 'search for the account (subitem 1)
    Set ltiItem = lvwDebtors.FindItem(txtFind, 1, 1, lvwPartial)

    Else 'search for a name
    'Unfortunatly we can only do partial searchs on the item.text not the subitem.text
    'This means we have to put the name we are searching for into the listitem.text before we can search
    intTotalItems = lvwDebtors.ListItems.Count

    For intIndex = 1 To intTotalItems
    lvwDebtors.ListItems(intIndex).Text = lvwDebtors.ListItems(intIndex).SubItems(2)
    Next intIndex

    'Now search on the text we just created
    Set ltiItem = lvwDebtors.FindItem(txtFind, , , lvwPartial)

    'Now remove the text strings
    For intIndex = 1 To intTotalItems
    lvwDebtors.ListItems(intIndex).Text = ""
    Next intIndex

    End If

    'Now select the item
    ltiItem.Selected = True
    lvwDebtors.SelectedItem.EnsureVisible
    lvwDebtors.HideSelection = False
    Exit Sub

    ErrorHandler:
    'inform the user that the item was not found
    Dim errNum
    errNum = Err.Number
    If errNum = 91 Then
    MsgBox "Sorry, the customer was not found", , "Customer Not Found"
    txtFind = ""
    txtFind.SetFocus
    Exit Sub

    Else
    MsgBox Err.Number & " - " & Err.Description & vbCrLf & "An error occurred in " & m_CurrentModule & "." & m_strCurrentProcedure & vbCrLf & "Please see the vendor."
    End If
    End Sub

  3. #3
    Guest
    Code:
    List1.Selected(0) = True

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