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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:44:03+00:00 2026-06-10T04:44:03+00:00

I’m trying to make a program that allows to drag and drop files to

  • 0

I’m trying to make a program that allows to drag and drop files to a ListView. I use ListView.InsertionMark to identify where to insert file. When I drop the file, the InsertionMark doesn’t disappear because the DragLeave event isn’t triggered; if I change drag drop effect to DragDropEffects.None, the DragLeave event is triggered when I release the mouse. Why is this happening?

Also, the document says “If there is a change in the keyboard or mouse button state, the QueryContinueDrag event is raised and determines whether to continue the drag, to drop the data, or to cancel the operation based on the value of the Action property of the event’s QueryContinueDragEventArgs.” But the QueryContinueDrag event is also not triggered.

public partial class MainForm : Form
{
    private ListView listView1 = new ListView();

    public MainForm()
    {
        InitializeComponent();

        this.Controls.Add(listView1);

        listView1.Dock = DockStyle.Fill;
        listView1.View = View.Details;
        listView1.Columns.Add("Test");
        listView1.Items.Add("0");
        listView1.AllowDrop = true;

        listView1.DragEnter += listView1_DragEnter;
        listView1.DragOver += listView1_DragOver;
        listView1.DragLeave += listView1_DragLeave;
        listView1.DragDrop += listView1_DragDrop;
        listView1.GiveFeedback += listView1_GiveFeedback;
        listView1.QueryContinueDrag += listView1_QueryContinueDrag;
    }

    private void listView1_DragEnter(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {
            e.Effect = DragDropEffects.Link | DragDropEffects.Scroll;
        }
        else
        {
            e.Effect = DragDropEffects.None;
        }
    }

    private void listView1_DragOver(object sender, DragEventArgs e)
    {
        // This is not done, only to show this problem.
        listView1.InsertionMark.Index = 0;
        listView1.InsertionMark.AppearsAfterItem = true;
    }

    private void listView1_DragLeave(object sender, EventArgs e)
    {
        listView1.InsertionMark.Index = -1;
    }

    private void listView1_DragDrop(object sender, DragEventArgs e)
    {
        // listView1.InsertionMark.Index = -1; // Is this really necessary?
    }

    private void listView1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
    {
        this.Text = "listView1_QueryContinueDrag";
    }

    private void listView1_GiveFeedback(object sender, GiveFeedbackEventArgs e)
    {
        this.Text = "listView1_GiveFeedback";
    }
}

Do I have to set listView1.InsertionMark.Index = -1 manually to hide the InsertionMark? Is there anyway to trigger the DragLeave event when drag drop effect is DragDropEffects.Link?

  • 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-10T04:44:04+00:00Added an answer on June 10, 2026 at 4:44 am

    When I drop the file, the InsertionMark doesn’t disappear because the DragLeave event isn’t triggered;

    DragLeave:

    The DragLeave event is raised when the user drags the cursor out of the control or the user cancels the current drag-and-drop operation.

    (Emphasis added)

    They did neither – they completed the drop. Why are you so surprised that this event didn’t fire then?


    Re: QueryContinueDrag:

    The QueryContinueDrag event enables the drag source to determine whether the drag-and-drop operation should be canceled.

    (Emphasis added)

    I could be wrong here, but in this instance, you appear to be the drag target, not the source.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.