Winforms ListView - Stop automatically checking when double clicking

If you don't want to turn of the DoubleClick messages completely, but just turn off the autocheck behaviour. You can instead do the following:

public class NoDoubleClickAutoCheckListview : ListView
{
    private bool checkFromDoubleClick = false;

    protected override void OnItemCheck(ItemCheckEventArgs ice)
    {
        if (this.checkFromDoubleClick)
        {
            ice.NewValue = ice.CurrentValue;
            this.checkFromDoubleClick = false;
        }
        else
            base.OnItemCheck(ice);
    }

    protected override void OnMouseDown(MouseEventArgs e)
    {
        // Is this a double-click?
        if ((e.Button == MouseButtons.Left) && (e.Clicks > 1)) {
            this.checkFromDoubleClick = true;
        }
        base.OnMouseDown(e);
    }

    protected override void OnKeyDown(KeyEventArgs e)
    {
        this.checkFromDoubleClick = false;
        base.OnKeyDown(e);
    }
}

Elegant isn't typically the word that jumps to mind when you have to hack the way the native Windows control works, but that's what required here. Do consider if you really want your control to behave differently from the listviews in any other program.

Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.

using System;
using System.Windows.Forms;

class MyListView : ListView {
    protected override void WndProc(ref Message m) {
        // Filter WM_LBUTTONDBLCLK
        if (m.Msg != 0x203) base.WndProc(ref m);
    }
}

I had a similar problem, and this is how I handled it. Basically if the item is checked while the cursor's x coordinate is greater than the checkbox's x coordinate, then I cancel the check (because it means the check was called when the user double clicked the item).

The margin of error with the number 22 is only if the user double clicks right after the check box (very hard to do).

NOTE: My code assumes the user will not double click the checkbox (either the user double clicks the item or single clicks the checkbox)

Sorry code is in VB :)

Private Sub lvComboLists_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles lvComboLists.ItemCheck
    Dim i As Integer = CType(sender, ListView).PointToClient(Cursor.Position).X
    If i > 22 Then
        e.NewValue = e.CurrentValue
    End If
End Sub