Results 1 to 11 of 11

Thread: Removing listview highlighted row [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213

    Question Removing listview highlighted row [RESOLVED]

    How do you reset the listview so that the last item clicked on is no longer highlighted?
    Last edited by GSIV; Dec 15th, 2003 at 04:33 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. Me.ListView1.Update()

  3. #3

    Thread Starter
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213
    Easy enough. Tnx!

  4. #4

    Thread Starter
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213
    oops... it doesn't work. Here's my code... after showing the messagebox, I want the highlighted item previously clicked to no longer be highlighted.

    Code:
        Private Sub lvwCensus_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwCensus.DoubleClick
            Dim intIndex As Integer = lvwCensus.SelectedIndices.Item(0)
            MessageBox.Show(intIndex)
            Me.lvwCensus.Update()
        End Sub

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ok , the only way I can think of right now is to send focus to another control . Something like this :

    VB Code:
    1. Private Sub lvwCensus_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwCensus.DoubleClick
    2.         Dim intIndex As Integer = lvwCensus.SelectedIndices.Item(0)
    3.         MessageBox.Show(intIndex)
    4. Me.Button1.Focus()
    5.     End Sub

  6. #6

    Thread Starter
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213
    I thought there might have been a better way, but that works fine. Thanks for the help.

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    found this... haven't test it

    VB Code:
    1. If lvw.SelectedItems.Count <> 0 Then lvw.Items.RemoveAt(lvw.SelectedItems(0).Index())

    http://www.pscode.com/URLSEO/vb/scripts/ShowCode!asp/txtCodeId!1578/lngWid!10/anyname.htm

    otherwise (haven't used listview), is there a selectedindex=-1 work?

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by nemaroller
    found this... haven't test it

    VB Code:
    1. If lvw.SelectedItems.Count <> 0 Then lvw.Items.RemoveAt(lvw.SelectedItems(0).Index())

    http://www.pscode.com/URLSEO/vb/scripts/ShowCode!asp/txtCodeId!1578/lngWid!10/anyname.htm

    otherwise (haven't used listview), is there a selectedindex=-1 work?
    lol , that will remove the listviewitem completely .

  9. #9
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Good... then it won't be selected anymore. Case solved

  10. #10
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

  11. #11

    Thread Starter
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213
    Good... then it won't be selected anymore.
    Haha! I never knew that learning could be so fun...ny!
    Thanks for the link

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