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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:31:18+00:00 2026-05-11T03:31:18+00:00

I have a winform with a listbox and a treeview. Once my listbox is

  • 0

I have a winform with a listbox and a treeview.

Once my listbox is filled with items, I want to drag them (multiple or single) from the listbox and drop them in a node in the treeview.

If somebody has a good example in C# that would be great.

  • 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. 2026-05-11T03:31:19+00:00Added an answer on May 11, 2026 at 3:31 am

    It’s been a while since I’ve messed with Drag/Drop so I figured I’ll write a quick sample.

    Basically, I have a form, with a listbox on the left, and a treeview on the right. Then I put a button on top. When the button is clicked, it just puts the date of the next ten days into the list box. It also populates the TreeView with 2 parents nodes and two child nodes. Then, you just have to handle all the subsequent drag/drop events to make it work.

     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();             this.treeView1.AllowDrop = true;             this.listBox1.AllowDrop = true;             this.listBox1.MouseDown += new MouseEventHandler(listBox1_MouseDown);             this.listBox1.DragOver += new DragEventHandler(listBox1_DragOver);              this.treeView1.DragEnter += new DragEventHandler(treeView1_DragEnter);             this.treeView1.DragDrop += new DragEventHandler(treeView1_DragDrop);          }          private void button1_Click(object sender, EventArgs e)         {             this.PopulateListBox();             this.PopulateTreeView();         }          private void PopulateListBox()         {             for (int i = 0; i <= 10; i++)             {                 this.listBox1.Items.Add(DateTime.Now.AddDays(i));             }         }          private void PopulateTreeView()         {             for (int i = 1; i <= 2; i++)             {                 TreeNode node = new TreeNode('Node' + i);                 for (int j = 1; j <= 2; j++)                 {                     node.Nodes.Add('SubNode' + j);                 }                 this.treeView1.Nodes.Add(node);             }         }          private void treeView1_DragDrop(object sender, DragEventArgs e)         {              TreeNode nodeToDropIn = this.treeView1.GetNodeAt(this.treeView1.PointToClient(new Point(e.X, e.Y)));             if (nodeToDropIn == null) { return; }             if(nodeToDropIn.Level > 0)             {                 nodeToDropIn = nodeToDropIn.Parent;             }              object data = e.Data.GetData(typeof(DateTime));             if (data == null) { return; }             nodeToDropIn.Nodes.Add(data.ToString());             this.listBox1.Items.Remove(data);         }          private void listBox1_DragOver(object sender, DragEventArgs e)         {             e.Effect = DragDropEffects.Move;         }          private void treeView1_DragEnter(object sender, DragEventArgs e)         {             e.Effect = DragDropEffects.Move;         }          private void listBox1_MouseDown(object sender, MouseEventArgs e)         {             this.listBox1.DoDragDrop(this.listBox1.SelectedItem, DragDropEffects.Move);         }       } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer filter-branch also keeps backup refs in .git/refs/original, which you'll also… May 11, 2026 at 11:10 am
  • added an answer I think this should do. size = min(image.Size) originX =… May 11, 2026 at 11:10 am
  • added an answer Basically, it's a broken interface. Ken Arnold and Bill Venners… May 11, 2026 at 11:10 am

Related Questions

I have a winform with a listbox and a treeview. Once my listbox is
I have a Winform with a BackgroundWorker. The BackgroundWorker, among other things, has to
I have a Winform application built with C# and .Net 2.0. I have a
I have a WinForm application built with VS 2008 (C#) and SQL Server Express
I have a WinForms application with a DataGridView control and a column of DataGridViewButtonCell
I have a WinForms application with a view where the user selects a single
I have a WinForms app with a datagridview and a bindingsource. I want the
I have a Winforms project with a bunch of User controls. I'd like the
I have a problem with a Winforms application written in Visual Studio 2005 (C#).
I have a winforms application that presently ships with a chm file for context-sensitive

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.