# Can't drag files into ListBox in Windows

**URL:** <https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711>\
**Category:** General\
**Created:** [April 14, 2021, 10:24am UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711 "2021-04-14T10:24:03Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [April 15, 2021, 7:48am UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/21 "2021-04-15T07:48:24Z")

</div>

Ask and ye shall receive. 🙂

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [April 15, 2021, 8:04am UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/22 "2021-04-15T08:04:07Z")

</div>

Creepy but uh thanks I guess.

---

<div class="post-metadata">

**Author:** ![Rui\_Batista](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@Rui\_Batista](https://forum.xojo.com/u/Rui_Batista)\
**Post date:** [April 15, 2021, 11:35am UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/23 "2021-04-15T11:35:05Z")

</div>

Just to report that… IT WORKED!!!  
Thank you.

---

<div class="post-metadata">

**Author:** ![Dale\_Arends](https://forum.xojo.com/user_avatar/forum.xojo.com/dale_arends/32/442_2.png) [@Dale\_Arends](https://forum.xojo.com/u/Dale_Arends)\
**Post date:** [April 15, 2021, 6:12pm UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/24 "2021-04-15T18:12:12Z")

</div>

Something about this thread had me wondering since I’ve never had a problem with dropping files on Listboxes, or any other control, that needed them. So, I tried a few tests with various FileTypes configurations. Basically, what I found was that if there is anything in the Extensions field it needs to be “recognizable” to the OS. So using `*.*` seems to be seen as ‘any and all files, including folders’. The same seems to be if there is nothing in the extensions field. So leaving that blank works the same as `*.*` apparently. Exactly why `.*` doesn’t work I don’t know but it sure doesn’t.

Of course, putting the dot in with extensions enables the filtering (and on Windows, the dot is necessary).

Now what I would like to see is a form where I could specify ‘any and all files but not folders of any kind’ .

Just for completeness, I tested it on Windows 10 with Xojo 2020r2.1 (since I can’t migrate to anything later until/unless they get the StyledTextPrinter issue fixed.)

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 15, 2021, 6:41pm UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/25 "2021-04-15T18:41:39Z")

</div>

To reject Directories, in Window1.DropObject Event, use:

```
If Obj.FolderItem.Directory Then
Return
End If

```

for example.

Not tested, written on the web browser.

---

<div class="post-metadata">

**Author:** ![Dale\_Arends](https://forum.xojo.com/user_avatar/forum.xojo.com/dale_arends/32/442_2.png) [@Dale\_Arends](https://forum.xojo.com/u/Dale_Arends)\
**Post date:** [April 16, 2021, 5:22pm UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/26 "2021-04-16T17:22:50Z")

</div>

> [@Emile\_Schwarz](#):
>
> To reject Directories, in Window1.DropObject Event, use:
> 
> ```auto
> If Obj.FolderItem.Directory Then
> Return
> End If
> 
> ```
> 
> for example.

Yeah, Emile, that’s what I generally have to do but it doesn’t give the visual feedback while dragging since the “filtering” doesn’t take place until the actual drop.

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [April 16, 2021, 5:30pm UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/27 "2021-04-16T17:30:08Z")

</div>

Put it on the DragEnter, see [RectControl.DragEnter - Xojo Documentation](https://documentation.xojo.com/api/deprecated/rectcontrol.html#rectcontrol-dragenter), the very last line of that page, remove the Not (ps. might want to tweak the code for multiple DragItems)

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 16, 2021, 7:34pm UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/28 "2021-04-16T19:34:18Z")

</div>

That is what we have to do on macOS…

---

<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:** [April 17, 2021, 11:19am UTC](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711/29 "2021-04-17T11:19:01Z")

</div>

The lack of visual indication (and, more generally, a way to prevent the OS to think the drag would be allowed when the user release the mouse) is something you shouldn’t just work-around.

[Previous page](https://forum.xojo.com/t/cant-drag-files-into-listbox-in-windows/62711.md?page=1)
