title: How to change property of all buttons in windows from?
body: <p>I have some buttons on <code>Form1</code>. I want to set their <code>FlatStyle</code> property to <code>FlatStyle.Popup</code>.
  I searched and wrote some code as below:</p>
  
  <pre><code>// List&lt;Control&gt; ButtonsList = new List&lt;Control&gt;();
   List&lt;Button&gt; ButtonsList = new List&lt;Button&gt;();
   public Form1()
          {
              InitializeComponent();
              this.Icon = Properties.Resources.autorun;  //Project-&gt;Properties-&gt;Resources-&gt;
              ButtonsList = GetAccessToAllButtons(this).OfType&lt;Button&gt;.ToList(); //*** hot line ***
  
              foreach(Button btn in ButtonList)
              {
                  btn.FlatStyle = FlatStyle.Popup;
              }
  
          }
  
  
  
   public IEnumerable&lt;Control&gt; GetAccessToAllButtons(Control thisClass)
          {
              List&lt;Control&gt; ControlsList = new List&lt;Control&gt;();
              foreach (Control child in thisClass.Controls)
              {
                  ControlsList.AddRange(GetAccessToAllButtons(child));
              }
              ControlsList.Add(thisClass);
              return ControlsList;
          }
  </code></pre>
  
  <p>But when I use <code>GetAccessToAllButtons()</code> in hot line of my code, VS generates this error:</p>
  
  <blockquote>
    <p>'System.Linq.Queryable.OfType(Query.Linq.IQueryable)' is a
    'method', which is not valid in the given context</p>
  </blockquote>
  
  <p>What is my mistake?</p>
  
  <p><strong>Edit:</strong> My reference at <a href="https://stackoverflow.com/a/5794767/4439444">here</a> missed the <code>()</code>. It is an accepted answer! Do we have a different situation at my reference? or it is only a typo?</p>