diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs
index 98fe274261e..92176d6e14a 100644
--- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs
+++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs
@@ -851,12 +851,12 @@ private static SnapLine[] GenerateNewToolSnapLines(Rectangle r)
///
/// Finds the array of components within the given rectangle. This uses the rectangle to
/// find controls within our control, and then uses those controls to find the actual
- /// components. It returns an object array so the output can be directly fed into
+ /// components. It returns an object list so the output can be directly fed into
/// the selection service.
///
- internal object[] GetComponentsInRect(Rectangle value, bool screenCoords, bool containRect)
+ internal List GetComponentsInRect(Rectangle value, bool screenCoords, bool containRect)
{
- ArrayList list = new ArrayList();
+ List list = new();
Rectangle rect = screenCoords ? Control.RectangleToClient(value) : value;
IContainer container = Component.Site.Container;
@@ -878,7 +878,7 @@ internal object[] GetComponentsInRect(Rectangle value, bool screenCoords, bool c
}
}
- return list.ToArray();
+ return list;
}
///
@@ -1255,16 +1255,14 @@ public override void InitializeNewComponent(IDictionary defaultValues)
return;
}
- object[] comps = parentDesigner.GetComponentsInRect(bounds, true, true /* component should be fully contained*/);
+ List selectedControls = parentDesigner.GetComponentsInRect(bounds, true, true /* component should be fully contained*/);
- if (comps is null || comps.Length == 0)
+ if (selectedControls is null || selectedControls.Count == 0)
{
//no comps to re-parent
return;
}
- ArrayList selectedControls = new ArrayList(comps);
-
//remove this
if (selectedControls.Contains(Control))
{
@@ -1889,8 +1887,8 @@ protected override void OnMouseDragEnd(bool cancel)
var selSvc = (ISelectionService)GetService(typeof(ISelectionService));
if (selSvc is not null)
{
- object[] selection = GetComponentsInRect(offset, true, false /*component does not need to be fully contained*/);
- if (selection.Length > 0)
+ List selection = GetComponentsInRect(offset, true, false /*component does not need to be fully contained*/);
+ if (selection.Count > 0)
{
selSvc.SetSelectedComponents(selection);
}
@@ -2135,7 +2133,7 @@ protected override void PreFilterProperties(IDictionary properties)
/// Control in the toolbox then drags a rectangle around four Buttons on the Form's surface. We'll attempt
/// to re-parent those four Buttons to the newly created Panel.
///
- private void ReParentControls(Control newParent, ArrayList controls, string transactionName, IDesignerHost host)
+ private void ReParentControls(Control newParent, List controls, string transactionName, IDesignerHost host)
{
using DesignerTransaction dt = host.CreateTransaction(transactionName);
var changeService = GetService();
@@ -2154,9 +2152,8 @@ private void ReParentControls(Control newParent, ArrayList controls, string tran
changeService?.OnComponentChanging(newParent, controlsProp);
//enumerate the lasso'd controls relocate and re-parent...
- foreach (object comp in controls)
+ foreach (Control control in controls)
{
- Control control = comp as Control;
Control oldParent = control.Parent;
Point controlLoc = Point.Empty;