title: How do test if a textbox is null using a list of textbox controls?
body: <p>I have created a list of the all the textboxes on a tab control in my winforms, c# application. Now what I would like to do is check each textbox in the list and test to see if that textbox is empty. If it is I would like to use the error provider to let the user know it needs to be filled. Here is the code I am using now.</p>
  
  <pre><code>//gathers the controls and adds them to a list on the main form
  public static List&lt;Control&gt; GetControls(Control form, string type)
      {
          var controlList = new List&lt;Control&gt;();
          foreach (Control childControl in form.Controls)
          {
              if (childControl.Name.Contains(type))
              {
                  controlList.Add(childControl);
              }
              if (childControl.HasChildren) GetControls(form, type);
          }
          return controlList;
      }
  
  
  //Created in a class called DataVerification
  public bool IsNotEmpty(string value, out string errorMessage)
      {
          errorMessage = "";
          if (value.Length == 0)
          {
              errorMessage = "This Field Is Required";
              return false;
          }
          return false;
      }
  
  
  //method that uses the DataVerification class and the error provider
   public void IsNotEmpty()
      {
          availableControls = GetControls(this.tabPage1, "Text");
          string errorMessage;
          DataVerification verify = new DataVerification();
          foreach (Control c in availableControls)
          {
              if (!verify.IsNotEmpty(c.Text, out errorMessage))
              {
                  ErrorProvider.SetError(c, errorMessage);
              }
          }
      }
  </code></pre>
  
  <p>Even if I could just display a messagebox that lets the user know which textboxes are empty would be fine. Any help would be appreciated. Thanks in advance.</p>