By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,190 Members | 1,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,190 IT Pros & Developers. It's quick & easy.

Drag and Drop Treeview Item into Listview

P: 18
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
Share this Question
Share on Google+
3 Replies


vekipeki
Expert 100+
P: 229
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

P: 18
Hi Dear,
I have added the event handler from front end design.

Thatz not a pronlem hope so
Jan 22 '09 #3

vekipeki
Expert 100+
P: 229
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

Post your reply

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