Wednesday, December 25, 2013

Code to color all panels and tabs in a windows form



  private static void setColor(Control parent,System.Drawing.Color color)
        {
            foreach (Control C in parent.Controls)
         {
             Debug.WriteLine(C.Name); 
                if (C.GetType() == typeof(TabPage)||
                 C.GetType() == typeof(Panel)||
                 C.GetType() == typeof(SplitterPanel)
                 )
                
             {C.BackColor = color;
             Debug.WriteLine("writing color");
                
             }
             if(C.Controls.Count > 0)    
                {
                 setColor(C, color);
            }
          }
        }

No comments:

Post a Comment