title: How to call button event handler on validation when I have two buttons?
body: <p>Here is the thing. I have two buttons on my form. One is buttonAccept, the other one is buttonClose. I have problem with validation because I don't know how to set condition in code. Here is the code:</p>
  
  <pre><code>private void txtValue_Validating(object sender, CancelEventArgs e)
      {
          string ext = txtValue.Text.Trim();
  
          if (!String.IsNullOrEmpty(ext))
          {
              //doSomething
          }
          else 
          {
              if(buttonAccept.Click ??)
              {
                  buttonAccept_Click(sender, e);
              }
              else buttonClose_Click(sender, e);
          }
      }
  </code></pre>
  
  <p>When I type code like this:</p>
  
  <pre><code>private void txtValue_Validating(object sender, CancelEventArgs e)
      {
          string ext = txtValue.Text.Trim();
  
          if (!String.IsNullOrEmpty(ext))
          {
              //doSomething
          }
          else 
          {
              buttonAccept_Click(sender,e)
          }
      }
  </code></pre>
  
  <p>the program will(ofcourse) call only Accept button even if I clicked on Close. </p>
  
  <p>I hope that somebody will know the answer.</p>