Results 1 to 3 of 3

Thread: ListView question?

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    ListView question?

    Ok guys this is killing me now! I have a ListView control in the form which has the checkbox enabled. This project is basically a windows explorer so when the user double clicks the folder the ListView should show the contents of the folder. So far so good! Now what I want is when the user double clicks the folder the checked state of the checkbox should not be changed. The only time the user changes the checked state of the folder when he clicks on the checkbox. Does any one know any property that should be set to achieve this?
    Thanks in advance!
    Attached Images Attached Images  

  2. #2

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: ListView question?

    For now I came up with this solution but I like to here some other suggestions too.
    vb Code:
    1. Public Class Form1
    2.     Dim doubleClicked As Boolean = False
    3.  
    4.     Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck
    5.         If doubleClicked Then
    6.             e.NewValue = e.CurrentValue
    7.             doubleClicked = False
    8.         End If
    9.     End Sub
    10.  
    11.     Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown
    12.         If e.Clicks = 2 Then
    13.             doubleClicked = True
    14.         End If
    15.     End Sub
    16. End Class

  3. #3

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: ListView question?

    Well I think there is no other ways of doing it so I stick with this code but I have another question. How can I know if the item is checked by mouse or through the code? Thanks for any replies!

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