Results 1 to 6 of 6

Thread: Problem with listview

  1. #1

    Thread Starter
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274

    Question

    i am having a little trouble with listview control. how can i check if the cursor was not clicked on an icon. i want to know if the user is clicking on the cursor or on the empty area.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb

    You can do something like this. Use the MouseDown event of the ListView to check if the user has selected anything in a ListView:
    Code:
    Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        Dim itmListItem As ListItem
        
        Set itmListItem = ListView1.HitTest(x, y)
        If itmListItem Is Nothing Then
            MsgBox "Nothing is selected."
        Else
            MsgBox "You selected " & itmListItem.Text
        End If
    End Sub
    Regards,

  3. #3

    Thread Starter
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274

    Thumbs down

    you suggestion works fine with single click, but when a user selects an item, and then double clicks on the listview control's blank area, the item which was selected the last time receives the focus. what i want is that when the user selects an item, and if he double clicks outside an item, the item should lose the focus just like in windows explorer.

    i hope you get what i mean.

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can try something like this:
    Code:
    Option Explicit
    Private itmListItem As ListItem
    
    
    Private Sub ListView1_DblClick()
        If itmListItem Is Nothing Then
            MsgBox "Nothing is selected."
        Else
            MsgBox "You selected " & itmListItem.Text
        End If
    End Sub
    
    
    Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        Set itmListItem = ListView1.HitTest(x, y)
    End Sub

  5. #5

    Thread Starter
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274
    but the item still doesnt loose the focus, it receives the focus again after double click, i want it to work like windows explorer.

  6. #6

    Thread Starter
    Hyperactive Member wasiq's Avatar
    Join Date
    Jan 2000
    Location
    Karachi, Sindh, Pakistan
    Posts
    274

    Question

    can anyone help,.....anyone???

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