Drag Drop

Feb 20 2009 2:34 AM

hi...

actually i using 2 list view boxes.  for box a i load multipitures by using  array. now . need to drag and drop pictures from box a to box b. that drag drop can be single picture and can be multi pictures at a time......so i wrote code to drag drop....it looks like working but......cannot see those draged pictures in box B.....

 

private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            this.listView1.DoDragDrop(this.listView1.SelectedItems[0], DragDropEffects.Copy);
        }

        private void listView2_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ListViewItem)))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

*************************************************************

over here i count how many items user select and creat array size acording to that number.

********************************************************   

     private void listView2_DragDrop(object sender, DragEventArgs e)
        {

            object[] array = new object[listView1.SelectedItems.Count];
            listView1.SelectedItems.CopyTo(array, 0);

            int count;
            count = array.Length;
          
        }

               
           
       

        private void listView2_ItemDrag(object sender, ItemDragEventArgs e)
        {
            this.listView2.DoDragDrop(this.listView2.SelectedItems[0], DragDropEffects.All);
        }

        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            ListViewItem item = e.Data.GetData(typeof(ListViewItem)) as ListViewItem;
            if (item != null)
            {
                Point pt = this.listView1.PointToClient(new Point(e.X, e.Y));
                ListViewItem hoveritem = this.listView1.GetItemAt(pt.X, pt.Y);
                if (hoveritem != null)
                {
                    hoveritem.Text = item.Text;
                }
            }
        }

        private void listView1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ListViewItem)))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

can any one HELP ME........


Answers (3)