title: How to call a button click event when i click another button in c#
body: <p>I have 2 buttons in my win app.</p>
  
  <p>Button1 do a task :</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      progressBar1.Value = 0;
      String[] a = textBox7.Text.Split('#');
      progressBar1.Maximum = a.Length;
      for (var i = 0; i &lt;= a.GetUpperBound(0); i++)
      {
          ansh.Close();
          progressBar1.Value++;
      }
  }
  </code></pre>
  
  <p>Button 2 do following</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
  {
      foreach (string item in listBox2.Items)
          textBox7.Text += item.Contains("@") ? string.Format("{0}#", item.Split('@')[0]) : string.Empty;
  }
  </code></pre>
  
  <p>I just want to use just one button for two events.</p>
  
  <p>But I want the event of button2 to be called before event that was called by button1.</p>
  
  <p>Means I want to use just one button instead of button 1 and 2.and when I click I want first thing to be done is getting listbox items in a textbox.  </p>
  
  <pre><code>{
      foreach (string item in listBox2.Items)
          textBox7.Text += item.Contains("@") ? string.Format("{0}#", item.Split('@')[0]) : string.Empty;
  }
  </code></pre>
  
  <p>and then the event of starting progress bar and closing connection x.</p>
  
  <pre><code>progressBar1.Value = 0;
  String[] a = textBox7.Text.Split('#');
  progressBar1.Maximum = a.Length;
  for (var i = 0; i &lt;= a.GetUpperBound(0); i++)
  {
      ansh.Close();
      progressBar1.Value++;
  }
  </code></pre>