title: Winform messagebox, How to disable YESNO options in C#
body: <p>I want to show YesNoCancel button in the message box, but at the same time, I wanted to disable YesNo button and enable only Cancel button.</p>
  
  <p>The reason I wanted to do like this is I am doing a demo application where I want to show users that particular feature is available but at the same time I don't want to give them save access.</p>
  
  <p>Following is my code, now to how to Disable YesNo button.</p>
  
  <pre><code>DialogResult result = MessageBox.Show("Save changes to " + this.Text.Substring(0, this.Text.Length - 1) + "?",
                                        "Save confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  </code></pre>
  
  <p>Actually I want to show YesNo buttons but I wanted to disable click acess for it. I wanted to show users 3 buttons YES , No and Cancel but click acess should be given only to cancel button. Is that possible? </p>
  
  <p><strong>edit:
  Thanks all for the answers.</strong></p>
  
  <p><strong>I have found soultion for my question</strong></p>
  
  <p><strong>My code for custom message box, I hope this might help someone</strong></p>
  
  <p><strong>customMsgBox.cs</strong></p>
  
  <pre><code>enter code here { public partial class CustomMsgBox : Form
  {
      static CustomMsgBox MsgBox;
      static string Button_id;
  
      public CustomMsgBox()
      {
          InitializeComponent();
      }
  
      internal static string ShowBox(string txtMessage, enumMessageIcon messageIcon)
      {
          MsgBox = new CustomMsgBox();
          MsgBox.labelCustomMsg.Text = txtMessage;
          MsgBox.addIconImage(messageIcon);
          MsgBox.ShowDialog();
          return Button_id;
      }
  
      /// &lt;summary&gt;
      /// We can use this method to add image on message box.
      /// I had taken all images in ImageList control so that
      /// I can easily add images. Image is displayed in 
      /// PictureBox control.
      /// &lt;/summary&gt;
      /// &lt;param name="MessageIcon"&gt;Type of image to be displayed.&lt;/param&gt;
      private void addIconImage(enumMessageIcon MessageIcon)
      {
          switch (MessageIcon)
          {
              case enumMessageIcon.Error:
                  pictureBox1.Image = imageList1.Images["Error"];  //Error is key 
                  //name in imagelist control which uniquely identified images 
                  //in ImageList control.
                  break;
              case enumMessageIcon.Information:
                  pictureBox1.Image = imageList1.Images["Information"];
                  break;
              case enumMessageIcon.Question:
                  pictureBox1.Image = imageList1.Images["Question"];
                  break;
              case enumMessageIcon.Warning:
                  pictureBox1.Image = imageList1.Images["Warning"];
                  break;
          }
      }
  
      private void btnCancel_Click(object sender, EventArgs e)
      {
          Button_id = "Cancel";
          MsgBox.Dispose();
      }
  
      private void btnNo_Click(object sender, EventArgs e)
      {
          Button_id = "No";
          MsgBox.Dispose();
      }
  
      private void btnYes_Click(object sender, EventArgs e)
      {
          Button_id = "Yes";
          MsgBox.Dispose();
      }
  }
  
  #region constant defiend in form of enumration which is used in showMessage class.
  
  internal enum enumMessageIcon
  {
      Error,
      Warning,
      Information,
      Question,
  }
  
  internal enum enumMessageButton
  {
      OK,
      YesNo,
      YesNoCancel,
      OKCancel
  }
  
  #endregion
  </code></pre>
  
  <p>}</p>
  
  <p><strong>main.cs</strong></p>
  
  <pre><code>String customResult = CustomMsgBox.ShowBox("Save changes to " + this.Text.Substring(0, this.Text.Length - 1) + "?", enumMessageIcon.Question);
  </code></pre>