I\'m trying to change the cursor that appears on a standard ListView when the cursor appears over an item. However I am getting a flickering effect as the mouse is changed t
The problem is that C# ListView Control is basically a wrapper around windows List View Control. So when we set the cursor to Arrow, the underlying listview control always defaulted to Hand cursor while our setting in the C# ListView class wanted it to be an Arrow. That's why we were getting that flickering, because underlying control was reverting back to Hand.
Here is the code that you need to add:
public const uint LVM_SETHOTCURSOR = 4158;
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
SendMessage(listView1.Handle, LVM_SETHOTCURSOR, IntPtr.Zero, Cursors.Arrow.Handle);
It's very important that you call the SendMessage from your Form's onLoad event because by then the underlying ListView control is completely initialized!
It's pretty simple actually, Have a great day! :)
Without having tried it, cursors are normally changed in response to WM_ SETCURSOR, so maybe you are in conflict with the default WM_ SETCURSOR handling of the ListView. I would try to create a new UserControl deriving from ListView and then trap WM_ SETCURSOR in WndProc and see if that helps.