No way to delete orphaned controls using the designer #12827
Labels
area-Analyzers/CodeFixes
A Roslyn Analyzer is either needed for the context, needs to be scope extended or fixed.
area-VSDesigner
Windows Forms out-of-proc designer related issues
customer-reported
Environment
Visual Studio Professional 2022
Version 17.12.4
.NET version
.NET 8
Did this work in a previous version of Visual Studio and/or previous .NET release?
Unsure, we've only noticed recently.
Issue description
We have a large Windows Forms project that we've migrated from .NET Framework 3.5 -> .NET Framework 4.8 -> .NET 8 during the last 5 years and we're finding forms that have a lot of orphaned controls. By that I mean controls that aren't attached to anything so you can't select them in the designer aside from the drop-down in the properties window.
We don't know how they got there, but we've not seen them prior to upgrading to .NET 8 which we used the .NET Upgrade Assistant for. They could have been there, but we haven't seen them until recently. They appear to have been generated a second time from existing controls that are in the form and then given the default name e.g. TabPage1 but that's just a guess. You can't actually select these inside the designer and its not possible to delete them without going into the designer generated code-behind file and deleting the code for them manually.
It would be nice if there was a compiler warning for orphaned controls and a way to delete them and their sub-controls from the designer itself so we don't have to risk breaking something.
Steps to reproduce
Unfortunately, I don't know how they got there. They're not easy to identify unless you're looking for a control in the properties window drop-down and happen to stumble upon one that doesn't display a selection box around it or change the view (like switching a tab page for example - if you switch to one thats an orphaned control it doesn't have a tabcontrol attached to switch to).
Diagnostics
The text was updated successfully, but these errors were encountered: