Menu

Item reorder using RearrangingDropSink only works in Details view

Johnny J
2018-04-18
2018-06-17
  • Johnny J

    Johnny J - 2018-04-18

    Hi
    It's my experience that item rearranging using a RearrangingDropSink only works if the OLV is in Details view.

    Is that correct? I need it in LargeIcon view, and even thougt it behaves like a drag and drop item reorder is in progress, nothing happens when I drop.

    It's no more complicated than this (as far as the reordering is concerned anyway. I also attempt to allow drag and drop of files from the Explorer on the same time, and that makes it all a little more complicated)

    RearrangingDropSink dropSink = new RearrangingDropSink(false);
    dropSink.Dropped += DropSink_Dropped;

    DocumentPageListView.DragSource = new SimpleDragSource();
    DocumentPageListView.DropSink = dropSink;

    Regards,
    Johnny J.

     
  • Johnny J

    Johnny J - 2018-04-18

    Yup - it's true. I did a quick and dirty workaround by copying all of the code for RearrangingDropSink to a new class and changing the RearrangeModels method like this:

    ** this.ListView.SuspendLayout();
    ** this.ListView.View = View.Details;

            switch (args.DropTargetLocation)
            {
                case DropTargetLocation.AboveItem:
                    this.ListView.MoveObjects(args.DropTargetIndex, args.SourceModels);
                    break;
                case DropTargetLocation.BelowItem:
                    this.ListView.MoveObjects(args.DropTargetIndex + 1, args.SourceModels);
                    break;
                case DropTargetLocation.Background:
                    this.ListView.AddObjects(args.SourceModels);
                    break;
                default:
                    return;
            }
    
            if (args.SourceListView != this.ListView)
            {
                args.SourceListView.RemoveObjects(args.SourceModels);
            }
    

    ** this.ListView.View = View.LargeIcon; **
    ** this.ListView.ResumeLayout();**

    Works fine, but it's definitely not the best solution to the problem... ;-)

    /Johnny

     
  • Phillip Piper

    Phillip Piper - 2018-04-27

    Yes, I didn't get around to implementing horizontal rearrangement :(

    However, I've just checked in the code to the SF repo which allow rearrangement on LargeIcon, SmallIcon and Tile views.

    Give it a try and see if it works for you :)

     
  • Dialecticus

    Dialecticus - 2018-06-12

    New code uses C#6 string interpolation, not available in VS2012 and earlier. All four lines in DropSink.cs are calls to System.Diagnostics.Debug.WriteLine.

     
  • Phillip Piper

    Phillip Piper - 2018-06-17

    Thanks. I forgot to take out the debugging lines.

    I've taken them out now.

     

Log in to post a comment.

MongoDB Logo MongoDB