我在程序中顯示了以下代碼。彈出一個消息框來顯示字段表單的內容。點擊確定後,另一個彈出詢問用戶信息是否正確。我想結合兩個地方,彈出消息框顯示錶單內容,並詢問信息是否正確,並附上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