title: How to call a method from another class in a button click event?
body: <p>I'm trying to call a non-static method (LoadingListBox) in my class (ListDisplay) from a button click event in my AddTask class.</p>
  
  <pre><code>namespace Project
  {
      public partial class ListDisplay : Form
      {
  
          public  void LoadingListBox()
          {
              //code
          }
      }
   }
  
  namespace Project
  {
      public partial class AddTask : Form
      {
           private void btnSubmit_Click(object sender, EventArgs e)
           {
               //code
               //I want to call LoadingListBox here
           }
      }
  }
  </code></pre>
  
  <p>I have tried creating an instance of <code>ListDisplay</code> by doing <code>ListDisplay listDisplayI = new ListDisplay();</code> and then writing <code>ListDisplay.LoadingListBox();</code> </p>
  
  <p>There were no errors with this code but when debugging the flow of control wouldn't go to the method it just carried on past it. 
  I have also tried doing what the answer suggests from this question:</p>
  
  <p><a href="https://stackoverflow.com/q/15571164/3187637">Call a public method of main class from another class</a></p>
  
  <p>But that comes up with an error as I can't overload the btnSubmit_Click method as the Designer freaked out. So I created a new method that had all of the code of btnSubmit_Click called <code>public static void addingTask(ListDisplay)</code> but I then had to create an instance of ListDisplay in order to put it as an argument in the btnSubmit_Click method hence ending up with two instances which is not what I want (due to answer of question).</p>
  
  <p>So now I have come up with nothing and would appreciate any help you could give in order to call this LoadingListBox method. 
  Thanks!</p>