我在程序中显示了以下代码。弹出一个消息框来显示字段表单的内容。点击确定后,另一个弹出询问用户信息是否正确。我想结合两个地方,弹出消息框显示表单内容,并询问信息是否正确,并附上YES/NO按钮。我试过将这两者结合起来无济于事。我相信我错过了一个语法概念。有任何想法吗?将两个C#消息框的内容合并为一个
//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);
是的,这正是我所需要的。我没有想到在两个附录()中添加。非常感谢你! – 2012-08-07 12:06:47
检查我的编辑:)你也可以用'StringBuilder.AppendFormat()'在一行中执行'AppendLine'和'string.Format()'' – 2012-08-07 12:10:47