473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Drag and Drop Treeview Item into Listview

Hi All,
I have tried by seeing an example. See the below code. Here I have a Problem. Treeview has already one root node and twochild nodes with it.
They have to be dragged and dropped in listview.

The main Problem is wen I drag an item..the Itemdrag event is not fired.?? Please try to resolve it.

Expand|Select|Wrap|Line Numbers
  1. private void tvwSalesProducts_ItemDrag(object sender, ItemDragEventArgs e)
  2.         { 
  3.             tvwSalesProducts.DoDragDrop(e.Item, DragDropEffects.Copy | DragDropEffects.Move);
  4.         }       
  5.         private void lstMultiProItems_DragEnter(object sender, DragEventArgs e)
  6.         {           
  7.             e.Effect = DragDropEffects.Copy | DragDropEffects.Move;             
  8.         }
  9.         private void lstMultiProItems_DragDrop(object sender, DragEventArgs e)
  10.         {
  11.                 if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
  12.                 {
  13.                     string[] Items = new string[5];
  14.                     TreeNode SourceNode;
  15.                     SourceNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
  16.                     Items[0] = Convert.ToString(SourceNode.Tag);
  17.                     Items[1] = SourceNode.Text.ToString();
  18.                     Items[2] = SourceNode.FirstNode.Text.ToString();
  19.                     Items[3] = SourceNode.LastNode.Text.ToString();
  20.                     lstMultiProItems.Items.Clear();
  21.                     lstMultiProItems.Columns.Add("ID", 100, HorizontalAlignment.Left);
  22.                     lstMultiProItems.Columns.Add("Product Name", 100, HorizontalAlignment.Left);
  23.                     lstMultiProItems.Columns.Add("Selling Price", 100, HorizontalAlignment.Left);
  24.                     lstMultiProItems.Columns.Add("Conversion", 100, HorizontalAlignment.Left);
  25.                     ListViewItem Item1 = new ListViewItem(Items);
  26.                     lstMultiProItems.Items.Add(Item1);
  27.                     lstMultiProItems.AllowColumnReorder = false;
  28.                     lstMultiProItems.FullRowSelect = true;
  29.                 }
  30.         }
Jan 22 '09 #1
3 5432
vekipeki
229 Expert 100+
Please format your code using the CODE tags before posting.

Have you actually attached the event handler to the TreeView's event?
Expand|Select|Wrap|Line Numbers
  1. tvwSalesProducts.ItemDrag += new ItemDragEventHandler(this.tvwSalesProducts_ItemDrag);
Jan 22 '09 #2
Hi Dear,
I have added the event handler from front end design.

Thatz not a pronlem hope so
Jan 22 '09 #3
vekipeki
229 Expert 100+
Yes, that the same. You should have the same line of code in your (formName).Designer.cs file.

Do you still have the problem? Did you try putting a breakpoint in tvwSalesProducts_ItemDrag to see if it really doesn't fire?
Jan 23 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: #Hai | last post by:
Hi, I have a TreeView control with hierarchy: A | - B // source | - C D // dest | - E Whenever draging B in to D, Item B is removed and B is added into D...
0
by: Norbert Heidbüchel | last post by:
Hi all, I have read a lot of postings and web pages about drag and drop and treeviews, but could not find an answer to my problem. Sorry, if I missed something. I am trying to drag and drop...
1
by: emferrari | last post by:
Hi everybody I have two treeviews, one of them is only to receive items dragged from the treeview1. I want to know how to drag a full node information to the treeview2. I know how to do that...
1
by: Matt Michael | last post by:
I'm writing an application that has a treeview that represents different user folders that a user can have messages in, and a listview that displays messages within that folder. The listview is...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
1
by: Sim | last post by:
Hello NG, I try to use drag and drop function between two list views. For this I found following code: ...
2
by: Tom Bean | last post by:
I wrote an C# application that uses drag and drop to copy the contents of one ListViewItem to another. I call DoDragDrop() in the ItemDrag event handler, however, the ItemDrag event is being fired...
0
by: munishbatra2002 | last post by:
hi all, we are using a gridview and a treeview control ... we want to drag a row from gridview control and drop it onto treeview control on a web page... we are using C# ASP.NET ... can anyone...
0
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I have some code that I use to drag and drop from treeview to treeview, now I want to adapt the code to drag and drop from listview to treeview. I am having problems adapting the code nor can I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.