Many modern applications operate on files that a user can upload to their system.

Image editors, code IDEs, and word processors are all examples.

Windows Form applications allow you to drag and drop UI elements such as panels or list boxes.

Laptop and plant on desk

you could use these UI elements to create your drag and drop functionality.

To add functionality to the drag and drop panel, you will need to add two events.

The “DragEnter” event will occur when you drag files over the panel.

Dragging panel from toolbox to canvas

you’re free to add a button to scrub the list when the user clicks on it.

If needed, you might alsodebug your Winforms applicationin Visual Studio at runtime.

This will help you understand what is happening in each line of code.

Winforms panel with properties window

Dragging ListBox element from toolbox to canvas

Winforms canvas with ListBox properties

Panel UI element highlighted on the canvas

List of events in properties window

New DragEnter event for panel

Changing tabs back to view canvas

New DragDrop event generated for panel in events list

Dragging button UI element from toolbox to canvas

Button highlighted in canvas with properties window open

Play button at the top of Visual Studio

Files dragged into panel at runtime

Files displaying inside panel at runtime

Many files inside panel with scrollbars

Panels list cleared at runtime