ListView with Checkboxs does not change the Checked status when you double-click?

xiaoxiao2021-03-17  192

If your ListView is Details mode, and you have Checkboxes, and you don't want to change the status of checkbox when you double-click, you can derive from ListView and overload the WndProc method. Below is the method:

public class MyListView: ListView {private const int WM_LBUTTONDBLCLK = 0x0203; public MyListView (): base () {} protected override void WndProc (ref Message m) {if (m.Msg == WM_LBUTTONDBLCLK) {Point p = PointToClient (new Point (Cursor.Position.y)); ListViewItem LVI = GetItemat (PX, PY); if (lvi! = Null) lvi.selected = true; OnDoubleClick (New EventArgs ());} else base. WndProc (Ref M);}}

转载请注明原文地址:https://www.9cbs.com/read-129719.html

New Post(0)