HoverItem stores null in ListView

When writing a custom control for listview: I override this method as follows:

protected override void OnDragDrop(DragEventArgs drgevent) { base.OnDragDrop(drgevent); // get the currently hovered row that the items will be dragged to Point clientPoint = base.PointToClient(new Point(drgevent.X, drgevent.Y)); ListViewItem hoverItem = base.GetItemAt(clientPoint.X, clientPoint.Y); 

Sometimes hoverItem becomes null :( It becomes null when I delete an item in the far right corner of the list. If I drop it somewhere in the list, there are elements and text there, it works fine if I drop it somewhere on items no text, then it will become null .... enter image description here

I attach the image for clarity

What is the problem? or do you think there are better ways to do this?

0
c # winforms
source share
1 answer

No problems. This is by design. There is no point where the red dot is. ListView has different view modes (View property), where there may be icons / text "blocks" that enclose each element, or there may be several columns of elements.

I think that if you set the View property to View.Details and set FullRowSelect to true, GetItemAt will fall into spaces to the end for each line, but I have to try this to be sure.

+1
source share

All Articles