Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6861163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:30:01+00:00 2026-05-27T02:30:01+00:00

As the title really – I have some code for reordering some thumbnails in

  • 0

As the title really – I have some code for reordering some thumbnails in a ListView (‘LargeIcon’ view format), and it works great when dragging an image to the right (i.e. a greater index). But when dragging to the left it doesn’t work at all.

Any ideas?

  private void lstImages_ItemDrag(object sender, ItemDragEventArgs e)
    {
        lstImages.DoDragDrop(lstImages.SelectedItems, DragDropEffects.Move);
    }

    private void lstImages_DragEnter(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection)))
        {
            e.Effect = DragDropEffects.Move;
        }
    }

    private void lstImages_DragDrop(object sender, DragEventArgs e)
    {
        if (lstImages.SelectedItems.Count == 0) return;

        Point p = lstImages.PointToClient(new Point(e.X, e.Y));
        ListViewItem dragToItem = lstImages.GetItemAt(p.X, p.Y);

        if (dragToItem == null) return;

        int dragIndex = dragToItem.Index;

        ListViewItem dataItem = (e.Data.GetData(typeof(ListView.SelectedListViewItemCollection)) as ListView.SelectedListViewItemCollection)[0];
        int itemIndex = dragIndex;
        if (itemIndex == dataItem.Index) return;

        itemIndex = itemIndex + 1;

        ListViewItem insertItem = (ListViewItem)dataItem.Clone();
        lstImages.Items.Insert(itemIndex, insertItem);
        lstImages.Items.Remove(dataItem);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:30:02+00:00Added an answer on May 27, 2026 at 2:30 am

    I modified your code a little bit and it works now. (Just the _DragDrop part). There seems to be a bug and it can be fixed by changing the alignment during Drag & Drop.

      listView1.Alignment = ListViewAlignment.Default;
      if (listView1.SelectedItems.Count == 0)
        return;
      Point p = listView1.PointToClient(new Point(e.X, e.Y));
      ListViewItem MovetoNewPosition = listView1.GetItemAt(p.X, p.Y);
      if (MovetoNewPosition == null) return;
      ListViewItem DropToNewPosition = (e.Data.GetData(typeof(ListView.SelectedListViewItemCollection)) as ListView.SelectedListViewItemCollection)[0];
      ListViewItem CloneToNew = (ListViewItem)DropToNewPosition.Clone();
      int index = MovetoNewPosition.Index;
      listView1.Items.Remove(DropToNewPosition);
      listView1.Items.Insert(index, CloneToNew);
      listView1.Alignment = ListViewAlignment.SnapToGrid;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pretty much what the title says really. We have some code that is .NET
As the title really, I'm in one part of my code and I would
the question's in the title really. I have an online form where, after a
I'm not really sure how to title this question but basically I have an
At first sorry for my really bad title! If you have a better title
I really have no idea what to title this so someone PLEASE feel free
The title really says it all. Under some (undetermined) conditions FB.getLoginStatus() just stops working
Erm... what the title says really; I have a PHP script executed by an
The clue is in the title really but I'm struggling to get code coverage
Edit : I've restored the original title but really what I should have asked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.