title: Get return value from pressed button
body: <p>I have a form that pops up at a specific event. It draws up buttons from an array and sets the Tag value to a specific value. So if you are to press or click this button the function should return the Tag value. </p>
  
  <p>How can I do this? And how do I know which button was clicked?
  At this moment the code returns DialogResult, but I want to return the Tag value from the function. How shall I modify my code so that it can do this?</p>
  
  <pre><code>public static DialogResult SelectBox(string title, string[] btnArray, string[] btnValueArray)
  {
      Form form = new Form();
  
      Button[] buttonArray;
      buttonArray = new Button[5];
  
      form.Text = title;
  
      for (int i = 0; i &lt; btnArray.Length; i++)
      {
          buttonArray[i] = new Button();
          buttonArray[i].Text = btnArray[i];
          buttonArray[i].Tag = new int();
          buttonArray[i].Tag = btnValueArray[i];
  
          buttonArray[i].TabStop = false;
          buttonArray[i].Location = new System.Drawing.Point(0, i * 40);
          buttonArray[i].Size = new System.Drawing.Size(240, 40);
      }
  
      form.ClientSize = new Size(240, 268);
      form.Controls.AddRange(new Control[] { buttonArray[0], buttonArray[1], buttonArray[2] });
      form.FormBorderStyle = FormBorderStyle.FixedDialog;
      form.StartPosition = FormStartPosition.CenterScreen;
      form.MinimizeBox = false;
      form.MaximizeBox = false;
  
      DialogResult dialogResult = form.ShowDialog();
      return dialogResult;
  }
  </code></pre>