I came up with this little trick on my own but i have a feeling that its wildly inefficient


I tried saying for each MatchType1 in the tabpage.controls

but it didn't seem to understand that i would onlly want to retreive matchtyp1's and not labels or textboxes


so i set it to loop through everything but if i do that i can't access the contols methods directly i have to create a new one and then set it equal to what C is pointing at.

anyway i thought i would run this past the experts to see if there is a better way to do this



c# Code:
  1. private void ClearRegion(string Region)
  2.         {
  3.             foreach (Control C in StringtoTabPage(Region).Controls)
  4.             {
  5.             if (C is MatchType1)
  6.             {
  7.                 MatchType1 holder = new MatchType1();
  8.                 holder = (MatchType1)C;
  9.  
  10.                 holder.ClearInfo();
  11.            
  12.             }
  13.                 if(C is MatchType2)
  14.                 {
  15.                     MatchType2 holder = new MatchType2();
  16.                     holder = (MatchType2)C;
  17.  
  18.                     holder.ClearInfo();
  19.                 }
  20.                 if (C is TextBox)
  21.                 {
  22.                     TextBox holder = new TextBox();
  23.                     holder = (TextBox) C;
  24.                     holder.Clear();
  25.                
  26.                 }
  27.            
  28.             }
  29.         }