Drag and drop multiple listbox rows

2 posts, 0 answers
  1. MNP
    MNP avatar
    40 posts
    Member since:
    Apr 2008

    Posted 25 Aug 2009 Link to this post

    The example posted here


    only allows single listboxitem moves. If I set the mousedown event to be

     Private Sub lstMembers_MouseDown(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles lstMembers.MouseDown 
          Dim lstBox As RadListBox = sender 
          lstBox.DoDragDrop(lstBox.SelectedItems, DragDropEffects.Move) 
       End Sub 

    The listbox does not select the proper values.

    Is there a way you can drag multiple values?


  2. Robert
    Robert avatar
    82 posts
    Member since:
    Jun 2009

    Posted 25 Aug 2009 Link to this post


    I've take the example and modified it to support multi-drag drop functionality:

            bool isMouseDown = false
            bool isDragAndDrop = false
            private void radListBox1_MouseDown(object sender, MouseEventArgs e) 
                isMouseDown = true
            private void radListBox1_MouseMove(object sender, MouseEventArgs e) 
                if (!isMouseDown || isDragAndDrop) return
                RadListBox listBox = sender as RadListBox; 
                listBox.DoDragDrop(listBox.SelectedItems.ToList(), DragDropEffects.Copy); 
                isDragAndDrop = true
            private void radListBox1_MouseUp(object sender, MouseEventArgs e) 
                isMouseDown = false
                isDragAndDrop = false
            private void radListBox1_DragOver(object sender, DragEventArgs e) 
                e.Effect = DragDropEffects.Copy;  
            private void radListBox1_DragDrop(object sender, DragEventArgs e) 
                RadListBox listBox = sender as RadListBox; 
                List<RadItem> items = (List<RadItem>)e.Data.GetData(typeof(List<RadItem>)); 
                RadListBox sourceListBox = items[0].ElementTree.Control as RadListBox; 
                foreach (RadItem lstBoxItem in items) 

    I subscribed to the same events on both listboxes.

    - Robert

  3. DevCraft R3 2016 release webinar banner
Back to Top