CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27

    Listview double-click delete row

    Hi guys,

    I have a listview with three columns.

    A user may double-click a row to remove that row from the listview (and all rows below move up to take the deleted row's place).

    Problem is, if the user double clicks in the empty space *below* the list items, the list item last selected is deleted!

    How do I stop this behaviour?

    I assume I'd have to test for validity of the double-click event but how do I test for a user double clicking the vacant area?

    Thanks,

    Mark

  2. #2
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    Hi..
    you need to use ListView1.HitTest method..
    It will return the ListItem under cursor when you call the method or it returns Nothing..

    the problem is to get the parameters to HitTest method (X,Y) Coordinates

    to do so you have 2 methods :
    1)Handle :
    Code:
    ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    to save the last x,y coordinates in global variables and pass them to HitTest in the DblClick event

    2) use the API GetCursorPos to get the location of mouse on the screen then convert it to x,y of the listview..

    Hope this can help..

  3. #3
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27
    That worked awesomely! I never even knew there was a "HitTest" method!

    Live and learn...

    Thanks for the answer!

    Mark

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

Featured