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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:56:45+00:00 2026-05-30T13:56:45+00:00

Consider this is a ListView that shows files and folders, I have already wrote

  • 0

enter image description here

Consider this is a ListView that shows files and folders, I have already wrote code for copy/move/rename/show properties …etc and I just need one more last thing. how to drag and drop in the same ListView like in Windows Explorer, I have move and copy functions, and I just need to get the items which user drops in some folder or in other way I need to get these two parameters to call copy function

void copy(ListViewItem [] droppedItems, string destination path)
{
 // Copy target to destination
}
  • 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-30T13:56:47+00:00Added an answer on May 30, 2026 at 1:56 pm

    Start by setting the list view’s AllowDrop property to true. Implementing the ItemDrag event to detect the start of a drag. I’ll use a private variable to ensure that D+D only works inside of the control:

        bool privateDrag;
    
        private void listView1_ItemDrag(object sender, ItemDragEventArgs e) {
            privateDrag = true;
            DoDragDrop(e.Item, DragDropEffects.Copy);
            privateDrag = false;
        }
    

    Next you’ll need the DragEnter event, it will fire immediately:

        private void listView1_DragEnter(object sender, DragEventArgs e) {
            if (privateDrag) e.Effect = e.AllowedEffect;
        }
    

    Next you’ll want to be selective about what item the user can drop on. That requires the DragOver event and checking which item is being hovered. You’ll need to distinguish items that represent a folder from regular ‘file’ items. One way you can do so is by using the ListViewItem.Tag property. You could for example set it to the path of the folder. Making this code work:

        private void listView1_DragOver(object sender, DragEventArgs e) {
            var pos = listView1.PointToClient(new Point(e.X, e.Y));
            var hit = listView1.HitTest(pos);
            if (hit.Item != null && hit.Item.Tag != null) {
                var dragItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
                copy(dragItem, (string)hit.Item.Tag);
            }
        }
    

    If you want to support dragging multiple items then make your drag object the ListView.SelectedIndices property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this scenario. We have an internal Rails 2 app that connects to a
Consider this example - I have a class called Report that has a field
Consider this code: enum { ERR_START, ERR_CANNOTOPENFILE, ERR_CANNOTCONNECT, ERR_CANNOTCONNECTWITH, ERR_CANNOTGETHOSTNAME, ERR_CANNOTSEND, }; char* ERR_MESSAGE[]
Consider this (rather pointless) javascript code: function make_closure() { var x = 123, y
Consider this code in a php file on my VPS server: <?php $url =
Consider I have two Horizontal ListView as shown below: list1 list2 I want to
Consider this code: int a = 5; if (a == 5 || a ==
Consider a View that defines a list of objects: App.ListView = Ember.View({ items: 'App.FooController.content'
Consider this code: #include <iostream> using namespace std; typedef int array[12]; array sample; array
Consider this code: public function showActiveJobsAction($slug) { $em = $this->getDoctrine()->getEntityManager(); $category = $em->getRepository('JobeetBundle:Category')->findBySlug($slug); if

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.