# Listbox Drag and drop Multiple Rows

**URL:** <https://forum.xojo.com/t/listbox-drag-and-drop-multiple-rows/78919>\
**Category:** General\
**Created:** [January 21, 2024, 6:58pm UTC](https://forum.xojo.com/t/listbox-drag-and-drop-multiple-rows/78919 "2024-01-21T18:58:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [January 21, 2024, 6:58pm UTC](https://forum.xojo.com/t/listbox-drag-and-drop-multiple-rows/78919/1 "2024-01-21T18:58:16Z")

</div>

This is API 1 but that should not make a difference… I am coding in 2019R1.1 but also tried the same project in 2023R4.

While at one time I was a listbox “expert” i have not done much with them for several years now an it’s even longer since I supposed dragging multiple rows so maybe I’m not understanding the docs about this any more.

In 2019R1 when I try to do drag rows with the code below shown below, it works fine when I try to drag one row … But does nothing happens when I try to drag multiple rows (no visible drag item).

Here is the code:

```auto

Function DragRow(drag As DragItem, row As Integer) Handles DragRow as Boolean
  If Not me.Selected(row) then Return False
  
  Dim DeltaY as Integer = me.MouseY -(me.HeaderHeight + (row-Me.ScrollPosition)*me.RowHeight) 
  
  drag.Text = Me.List(row)
  
  Dim ub As Integer = me.ListCount - 1
  

  For i as Integer = me.ListIndex To ub
    If i = Row Then Continue
    If Me.Selected(i) Then
      drag.AddItem(0, me.HeaderHeight + (i-Me.ScrollPosition)*me.RowHeight + DeltaY, me.Width, me.RowHeight)
      drag.Text = Me.List(i) 
    End If
  Next
  Return True // allow the drag
End Function

```

On 2023R4 I now see drag items for multiple rows… Too many of them!!! See below:

What am I doing wrong , or is this a bug?  
Thanks,  
-karen

 ![Screen Shot 2024-01-21 at 1.35.08 PM](https://forum.xojo.com/uploads/default/original/3X/6/a/6a0617868800ffda95675345c45e0a377259a03a.png)

---

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [January 23, 2024, 5:13pm UTC](https://forum.xojo.com/t/listbox-drag-and-drop-multiple-rows/78919/2 "2024-01-23T17:13:12Z")

</div>

No one else has seen this issue?

Am i doing something wrong, maybe misunderstanding the docs, or is this a xojo bug?

If it’s a bug does anyone know of a workaround (outside of having only one drag item and drawing a single picture with all the rows on it)?

(the full code draws the cell contents semi transparently so you an see the content you are dragging)

- Karen

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [January 24, 2024, 7:40am UTC](https://forum.xojo.com/t/listbox-drag-and-drop-multiple-rows/78919/3 "2024-01-24T07:40:33Z")

</div>

> [@KarenA](#):
>
> No one else has seen this issue?

Yes, I’ve seen it regularly. But since I don’t know a fix, nor a cause, I’ve not had any helpful answer to give, sorry.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [January 24, 2024, 10:00am UTC](https://forum.xojo.com/t/listbox-drag-and-drop-multiple-rows/78919/4 "2024-01-24T10:00:01Z")

</div>

I think this was discussed a while ago but I wasn’t able to find the forum thread. As far as I remember the macOS functionality with the badges overrides whatever Xojo does. I use NSTableviewMBS and had to do some finagling to get a nice drag image.

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [January 24, 2024, 10:08am UTC](https://forum.xojo.com/t/listbox-drag-and-drop-multiple-rows/78919/5 "2024-01-24T10:08:59Z")

</div>

IIRC I created a drag picture, and not the additem method to go around this  
and yes it’s a macos change that prevent the drag from beeing the same between these xojo versions

edit: I did use drap.picture = mypicture, and not drag.text but it should not change a lot for this problem  
and more I use drag.additem(0,0,0,0) for each selected item.
