Results 1 to 4 of 4

Thread: Highlighting row in a listview

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2001
    Location
    BX, NY
    Posts
    42

    Question Highlighting row in a listview

    The following is my code for highlighting a specific row on a listview based on two variables being equal. Problem is that the correct row gets highlighted only after I scroll up or down. Tried the Refresh method on the listview to no avail. And I've changed the order of the lines between the if..end if with no success. Please help. Thx.

    Private Sub selectRow(Index As Integer, cObj As CollectionClassObject)
    Dim l_DetailID As Long
    Dim i As Integer

    For i = 1 To lvDetails(Index).ListItems.Count
    l_DetailID = cObj.Item(lvDetails(Index).ListItems(i).Key).DetailID
    If m_DetailID = l_DetailID Then
    lvDetails(Index).ListItems(i).Selected = True
    lvDetails(Index).SetFocus
    Exit For
    End If
    Next i

    End Sub

  2. #2
    Member
    Join Date
    Jun 2002
    Location
    India
    Posts
    40
    Hi,


    I think what u have done is right. The only thing u need to do is to insert the following code before u set the seleted item.

    lvDetails.HideSelection = False

    or

    u can uncheck this property in the property page of the list view.

    Bye & regards,
    Ravi.

  3. #3
    Junior Member
    Join Date
    May 2003
    Posts
    27
    VB Code:
    1. If (m_DetailID = l_DetailID) Then Set lvDetails.SelectedItem = lvDetails(Index).Listitems(i)

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2001
    Location
    BX, NY
    Posts
    42
    thx!! Setting HideSelection to false worked.

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