I am trying to delete Controls dynamically, without knowing the parent. But I keep getting a "System.NullReferenceException" in mscorlib.dll when I debug.
My Code:
//Delete Controls
        List<PictureBox> toDelete = severalControlsFromDifferentPanels;
        for (int i = toDelete.Count - 1; i >= 0; --i)
        {
            Control parent = toDelete[i].Parent;
            parent.Controls.Remove(toDelete[i]);
        }
What am I missing here? Am I overseeing something obvious? thanks in advance!
 
     
    