The problem you are facing is checking Controlson nullto determine if it is empty. The property Controlswill never be null, but instead will be nonempty and has a length of 0 when empty. for instance
if (flowLayoutPanel1.Controls.Count == 0) {
}
source
share