ListView: Can I prevent checkbox getting set on a double-click?

  • Thread starter Thread starter Peter Steele
  • Start date Start date
P

Peter Steele

I suspect I know the answer but I'll ask anyway. I have a ListView with
fullrow select and checkboxes enabled. When a double-click is done on a row
it automatically sets/unsets the checkbox for that row. I don't want this to
happen--I only want the checkbox to be set/unset by explicitly clicking on
the checkbox. I've got a hack that sort of solves it but you can see the
checkbox toggle itself during the double-click. Is there anyway to prevent
the double-click event from modifying the value of the checkbox?

Peter
 
You could to it the brute force way by creating your own class that inherits from IMessageFilter that filters all double click OS messages to the listview control. You add the filter to the application message pump by calling the Application.AddMessageFilter() and pass in the instance of your custom IMessageFilter

The other brute force way is to override the ListView's WndProc method and check each message object for the double click message. If you find it, just dont pass it onto base.WndProc(ref msg). If you dont find it, make sure that you pass the message onto the base control's WndProc function

One thing, either of these will affect the performance of your app.
 
Back
Top