dotnet / dotnet/winforms

Controls from the toolbox cannot be dropped into UserControl docked in a Panel

Open
#15,057 0 comments 0 reactions 0 assignees View on GitHub
untriaged
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### Environment

Visual Studio 18.8.2

### .NET version

.NET 10

### Did this work in a previous version of Visual Studio and/or previous .NET release?

Seemingly not

### Issue description

The issue is reproduced within a .NET Winforms designer. When a form outline is composed as `Form -> Panel (Dock=Fill) -> Panel (Dock=Fill) -> UserControl (Dock=Fill)` dragging a new control onto the UserControl renders as if `Effect` is `None` and thus cannot be placed. The focus during the drag operation stays on the Toolbox window.

https://github.com/user-attachments/assets/62d07c56-538f-4b66-ba05-a342554b5f0f

Expected results: the dropped control is added to the innermost container that can accept children.
Actual results: the drag is rejected with Effect = None and nothing is created.

If in the same scenario the mouse moves rather slow to register at form bounds (or any other surface, NOT related to UserControl) so that the focus moves to the designer tab, the drag succeeds.

https://github.com/user-attachments/assets/8da13971-7c31-4e41-b3c8-aa54a5009812

This behavior is NOT observed when only one Panel is used.

See the project for reference

[Sample.zip](https://github.com/user-attachments/files/31948986/Sample.zip)

### Steps to reproduce

1. Place a Panel (Dock=Fill) onto a Form.
2. Place another Panel (Dock=Fill) into the first one.
3. Place a UserControl (Dock=Fill) inside the second Panel
4. Drag (yes, clicking is not enough) a control onto the UserControl, the drag will fail.
4.1. If Dragging slowly enough OR touches the tab header OR the form header, the drag will succeed.

### Diagnostics

```text

```

Contributor guide

Open the contributing guide

Research direction

Start with the attached Sample.zip and reproduce the drag operation in the .NET WinForms designer using the nested Form, Panels, and UserControl described in the issue. Compare Toolbox focus and drag behavior with one Panel versus two Panels, including slow movement to the form or designer tab. Done means a control can be dragged onto the innermost UserControl and is added to the appropriate container instead of being rejected with Effect = None.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.