Skip to main content
Control collections don't implement IEnumerable<T>, it turns out
Source Link
Errorsatz
  • 1.4k
  • 8
  • 9

You have an error there, unless you wanted to include all child controls regardless of whether they're contained. It should be:

if (rect.IntersectsWith(ctl.Bounds)) 
{    
    Selected.Add(ctl);
    Selected.AddRangeforeach (Control ct in ctl.Controls) 
    {
        Selected.Add(ct);
    }
}

As for the test, instead of two cases you can use:

if(rect.IntersectsWith(ctl.Bounds) == bContained)

You have an error there, unless you wanted to include all child controls regardless of whether they're contained. It should be:

if (rect.IntersectsWith(ctl.Bounds)) 
{    
    Selected.Add(ctl);
    Selected.AddRange(ctl.Controls);
}

As for the test, instead of two cases you can use:

if(rect.IntersectsWith(ctl.Bounds) == bContained)

You have an error there, unless you wanted to include all child controls regardless of whether they're contained. It should be:

if (rect.IntersectsWith(ctl.Bounds)) 
{    
    Selected.Add(ctl);
    foreach (Control ct in ctl.Controls) 
    {
        Selected.Add(ct);
    }
}

As for the test, instead of two cases you can use:

if(rect.IntersectsWith(ctl.Bounds) == bContained)
Source Link
Errorsatz
  • 1.4k
  • 8
  • 9

You have an error there, unless you wanted to include all child controls regardless of whether they're contained. It should be:

if (rect.IntersectsWith(ctl.Bounds)) 
{    
    Selected.Add(ctl);
    Selected.AddRange(ctl.Controls);
}

As for the test, instead of two cases you can use:

if(rect.IntersectsWith(ctl.Bounds) == bContained)