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

  • Home
  • SEARCH
  • 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 4026412
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:58:02+00:00 2026-05-20T10:58:02+00:00

I need drag from window1.listbox drop in window2.panel. A write: public partial class Form1

  • 0

I need drag from window1.listbox drop in window2.panel.

A write:

public partial class Form1 : Form
{
    Routers r = new Routers();
    public Form1()
    {
        InitializeComponent();

        r.Show();

        panel1.DragOver += new DragEventHandler(panel1_DragOver);
        panel1.DragEnter += new DragEventHandler(panel1_DragEnter);
        panel1.MouseUp += new MouseEventHandler(panel1_MouseUp);
        panel1.DragDrop += new DragEventHandler(panel1_DragDrop);
        panel1.AllowDrop = true;

        this.AllowDrop = true;
        this.DragDrop += new DragEventHandler(Form1_DragDrop);
    }

    void Form1_DragDrop(object sender, DragEventArgs e)
    {
        throw new NotImplementedException();
    }

    void panel1_DragDrop(object sender, DragEventArgs e)
    {
        if (isDrop == false)
        {
            isDrop = true;
            Button b = new Button();
            b.Text = (string)e.Data.GetData(DataFormats.StringFormat);
            b.Location = new Point(e.X, e.Y);

            this.panel1.Controls.Add(b);
        }
    }

    void panel1_MouseUp(object sender, MouseEventArgs e)
    {
        if (isDrop)
        {
            isDrop = false;
        }
    }
    bool isDrop = false;

    void panel1_DragEnter(object sender, DragEventArgs e)
    {
        isDrop = false;
        if (e.Data.GetDataPresent(DataFormats.StringFormat)) 
            e.Effect = DragDropEffects.None;
    }
    void panel1_DragOver(object sender, DragEventArgs e)
    {
        e.Effect = DragDropEffects.None;
    }
}

write window2

   public partial class Routers : Form
    {
        public Routers()
        {
            InitializeComponent();

            this.listBox1.MouseDown += new MouseEventHandler(listBox1_MouseDown);
            this.listBox1.DragOver += new DragEventHandler(listBox1_DragOver);

        }


        private void listBox1_DragOver(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;
        }

        private void listBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (this.listBox1.SelectedItem != null)
            {
                string item = this.listBox1.SelectedItem.ToString();
                this.listBox1.DoDragDrop(item, DragDropEffects.Move);
            }
        }


    }

DragDrop event not work.
and does not change the cursor when dragging

  • 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-20T10:58:03+00:00Added an answer on May 20, 2026 at 10:58 am

    You need to set e.Effect to something other than None when dragging over the destination.

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

Sidebar

Related Questions

I need to write a sophisticated website that does AJax, drag and drop, component
i need to drag from grlRicProd to drop into grlInsOrd grlIRicProd: ..... id: 'grlRicProd',
I need to drag and drop a component from a frame1 to a frame2
I have a container that contains an image that I need to drag from
I need to create a drag and drop system in swing where an image
i need to be able to drag and drop my picturebox with an image
Folks, I need a solution that allows drag-and-drop cell over the table. The cells
jQuery data grid with items&columns drag&drop, Items sort. Is there any? I need: Dragable\Dropable
I want to enable drag and drop from our windows forms based application to
Does anyone already implemented Drag & Drop of email messages from Outlook and/or Thunderbird

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.