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 7831753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:52:21+00:00 2026-06-02T11:52:21+00:00

I have a small file explorer application [WINFORMS], and i use ListView Control to

  • 0

I have a small file explorer application [WINFORMS], and i use ListView Control to explore items.
So the listView display the files and the folders from the current address [From local Computer].
i need to enable drag&drop functionality to let a File/Folder easy to move/copy to another Folder in the same Address.
each item has some preperties:

  • (item.Text/item.Name) has the file/folder Name.
  • item.ToolTipText has the file/folder Path.
  • item.SubItems[ 1 ].Text for a file it will respresent the file size like "13.45 MB" and for a folder, it’s going to be string.Empty [However, there’s several way to know whether its a file or a folder].

    I’ve seen many tutorials about how to use drag&drop in listview, but it was like from Windows File Explorer to ListView, or from a ListView to another one, but in my case i need to know how to drag&drop in the same ListView.

    I’ve Enabled AllowDrop property of the ListView. and also Activated the following functions:

        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
        }
    
        private void listView1_DragEnter(object sender, DragEventArgs e)
        {
        }
    
        private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
        }
    

    enter image description here

    UPDATE:

    i tried to use this :

    private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            ListViewItem item = (ListViewItem)e.Data.GetData(typeof(ListViewItem)); //this should be the target item (FOLDER)
            StringBuilder s = new StringBuilder();
            foreach (ListViewItem i in listView1.SelectedItems)
            {
                s.AppendLine(i.Text);
            }
            MessageBox.Show("DRAGGED ITEM : " + s.ToString() + "TARGET ITEM : " + item.Text);
        }
        private void listView1_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
        }
        private void listView1_MouseDown(object sender, MouseEventArgs e)
        {
            var item = listView1.GetItemAt(e.X, e.Y);
            if (item != null)
            {
                listView1.DoDragDrop(item, DragDropEffects.Copy);
            }
        }
    

    at listView1_MouseDown i get the item which mouse points onto, but it gives me the item before i drop the dragged item, so if i am dragging a folder named “SWImg” to the folder “ODDFiles” , the messageBox shows "SWImg - SWImg"

    then i replaced listView1_MouseDown with listView1_ItemDrag :

    private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            if (e.Item != null)
            {
                listView1.DoDragDrop(e.Item, DragDropEffects.Copy);
            }
        }
    

    same result :S.

    • 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-06-02T11:52:23+00:00Added an answer on June 2, 2026 at 11:52 am

      I’ve figured it out.

      private void listView1_DragDrop(object sender, DragEventArgs e)
          {
              if (listView1.SelectedItems.Count == 0) { return; }
              Point p = listView1.PointToClient(MousePosition);
              ListViewItem item = listView1.GetItemAt(p.X, p.Y);
              if (item == null) { return; }
              List<ListViewItem> collection = new List<ListViewItem>();
              foreach (ListViewItem i in listView1.SelectedItems)
              {
                  collection.Add((ListViewItem)i.Clone());
              }
              if ((e.Effect & DragDropEffects.Move) == DragDropEffects.Move)
              {
                  Thread thMove = new Thread(unused => PasteFromMove(item.ToolTipText, collection));
                  thMove.Start();
              }
              else
              {
                  Thread thCopy = new Thread(unused => PasteFromCopy(item.ToolTipText, collection));
                  thCopy.Start();
              }
      
          }
      
          private void listView1_DragOver(object sender, DragEventArgs e)
          {
              if ((e.KeyState & 8) == 8)
                  e.Effect = DragDropEffects.Copy;
              else
                  e.Effect = DragDropEffects.Move;
          }
      
          private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
          {
              listView1.DoDragDrop(e.Item,DragDropEffects.All);
          }
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I have a small utility that I use to download an MP3 file from
    I have a small application to convert several file formats, with a main windows
    I have a small C# ASP.NET web application which generates several PNG image files
    I'm trying to create a Properties form for selected items from my small file
    Im developing a small file explorer, how do i set Back button. i have:
    I have written a small batch file that copies an exe from solution to
    I have a program that creates a small file in the Bin directory for
    I have a small job that takes a text file of email/zip codes and
    I have a small java program that reads a file in, in eclipse i
    I have a small program that reads in a file and processes the data

    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.