diff ServerMonitor/Controls/CheckControl.cs @ 2:453ecc1ed9ea

Disk space check
author Brad Greco <brad@bgreco.net>
date Sun, 06 Jan 2019 20:49:08 -0500
parents 3e1a2131f897
children 3142e52cbe69
line wrap: on
line diff
--- a/ServerMonitor/Controls/CheckControl.cs	Tue Jan 01 21:14:47 2019 -0500
+++ b/ServerMonitor/Controls/CheckControl.cs	Sun Jan 06 20:49:08 2019 -0500
@@ -27,9 +27,12 @@
             IEnumerable<Panel> panels = CheckGroupBox.Controls.OfType<Panel>();
             foreach (Panel panel in panels)
             {
-                CheckBox mainCheckBox = panel.Controls.OfType<CheckBox>().OrderBy(c => c.Left).First();
-                mainCheckBox.CheckedChanged += CheckControl_CheckedChanged;
-                DisablePanelByCheckBox(mainCheckBox);
+                CheckBox mainCheckBox = panel.Controls.OfType<CheckBox>().OrderBy(c => c.Left).FirstOrDefault();
+                if (mainCheckBox != null)
+                {
+                    mainCheckBox.CheckedChanged += CheckControl_CheckedChanged;
+                    DisablePanelByCheckBox(mainCheckBox);
+                }
             }
         }