I have the following code shown below in my program. One of the message boxes pops up to display the contents of field forms. After hitting OK, another one pops up asking the user if the information is correct. I would like to combine the two where the message box will pop up displaying the form contents and asking if the information is correct, accompanied by a YES/NO button. I’ve tried combining the two to no avail. I believe I am missing a syntactical concept. Any ideas?
//shows contents of form fields
StringBuilder MessageText = new StringBuilder();
MessageText.AppendLine(string.Format("Coil#: {0}", coil_Num.Text));
MessageText.AppendLine(string.Format("Location: {0}", location_box.Text));
MessageText.AppendLine(string.Format("Sub-Area: {0}", sub_area_box.Text));
MessageText.AppendLine(string.Format("Row: {0}", row_Num.Text));
MessageBox.Show(MessageText.ToString());
//asks if info is correct, with a YES/NO button and question mark
DialogResult result1 = MessageBox.Show("Information is correct?",
"Double Check Form Information",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Question);
Something like this? Of course this last text could also be appended to the StringBuilder.
If you only want Yes/No buttons then change
MessageBoxButtons.YesNoCanceltoMessageBoxButtons.YesNo.Finally check the result like this:
of course you have to add/remove the cancel option depending on if you include the button or not.