ListView Drag Drop reorder items

0
0

I did not see this supported out of the box. So I was trying to adapt some Winforms Code. But it appears that ListView.GetItemAt(cp.X, cp.Y) is not implemented.

Is there a way to drag and reorder items in listview ?

https://support.microsoft.com/en-us/help/822483/the-listview-control-does-not-support-drag-and-drop-functionality-for

  • You must to post comments
0
0

Cristian, Edmond,

sorry for the very late reply, just noticed this topic was still pending.

Anyways, here is the old sample with the theme mixin added to benefit from the drop state.

Hope it helps.

Best regards
Frank

  • You must to post comments
0
0

Hi Edmond,

we checked again and it can be achieved by using the drop state that will be available to ListView items with the next Wisej build.
Then you can add a theme mixin and use virtually any highlight option.
In this sample I am highlighting the left border in red:

insertion

The drop state is available for any widget that you can drop onto, e.g. also DataGridView cells etc.
Since it´s themeable there is almost no limit to what can be done here.

Will notify you when the new Wisej build will be available.

Best regards
Frank

Attachment
  • edmond girardi
    Frank – was this ever implemented ? Now that we have a lot of users in the application – they find it difficult to see where exactly the item will be dropped in between other items. Do you still have this sample where the screenshot was taken from ?
  • Cristian Zerbinati
    Hi Frank, I need too this feature, I’m not eable to show the red separator. InsertionMark it is not present
  • You must to post comments
0
0

Hi Edmond,

I have built a simple sample that shows how to redirect ListView items by drag & drop:

http://wisej.s3.amazonaws.com/support/attachments/ReorderListViewItems.zip

Please make sure to use it with Wisej dev build 1.5.17 to benefit from the latest enhancements.

Hope that helps.

Best regards
Frank

 

  • edmond girardi
    Thanks Frank. I changed the listview to Details view and added a column header. It appears to be working for me in the sample. I’ll apply to my application and give it a try with the users. One other question- is there any way to get an insertion bar in there that shows where your item is going to appear ? This is something that pretty much all WinForms extended ListViews have done to make it easier for the user to see what they are about to do. https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/how-to-display-an-insertion-mark-in-a-windows-forms-listview-control
  • edmond girardi
    Frank – Actually – the Clone is not cloning the subitems of the DragItem. It’s only getting the main LIstViewItem itself. Winforms .net 4.0 Docs says Clone : An object that represents an item that has the same text, image, and subitems associated with it as the cloned item. My work around was to manually reassign the subitem(s), but it should probably clone the entire thing in one call. insertItem.SubItems.Add(DragItem.SubItems[1].Text);
  • You must to post comments
0
0

Hi Edmond,

functions like GetItemAtX cannot be supported on the server side.

But we will support more information in e.DropTarget for ListViews like we already do for TreeViews.

It´s logged as enhancement #1569.

We´ll inform you when it´s available.

Best regards
Frank

  • You must to post comments
0
0

Hi Edmond,

please refer to this discussion and Luca´s code. It should help you get there:

https://wisej.com/support/question/listview-details-drag-drop

Best regards
Frank

  • edmond girardi
    Yeah, I came across this. But the problem is to reorder the items in the ListView I have to know which item I’m hovering the drag over. That’s what the GetItemAt() Method was doing in the Winforms Sample. The user wants new items that are dragged into the list from another Window (currently adding at the end of the list) to be dragged around in the list to reorder the new one into the correct position.
  • edmond girardi
    From some small tests it appears that maybe you cant drag something and drop it into the same ListView control – I get the “No” circle with the slash through it when I’m still over the same ListView control during the drag.
  • Luca (ITG)
    You need to set the effect. Check e.AllowedEffects and e.Effect in either DragOver or DragEnter. It’s the same as in Winforms. With Wisej you can also set a custom image to drag around.
  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.