为什么 ShowDialog() 显示旧消息?
我为 ShowDialog 输入了“测试消息”,然后将其更改为新消息。但它仍然显示“测试消息”
新代码
private void addButton_Click(object sender, EventArgs e)
{
//MessageBox.Show("Debugging Add Test Button", "My Test Application",
//MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
//Display Add Alarm form
AlarmForm alarmForm = new AlarmForm();
//Display alarmForm instance, assgn the results to a Dialog result
DialogResult dialogResult = alarmForm.ShowDialog();
//Check return value, and extract data
if (dialogResult == DialogResult.OK) // Add Alarm
{
//Extract Alarm information from the Form using the accessor
Alarm alarm = alarmForm.Alarm;
//Add the alarm object to our list
_alarms.Add(alarm);
//Update the Listbox
refreshAlarmList();
}
}
旧代码
private void addButton_Click(object sender, EventArgs e)
{
MessageBox.Show("Debugging Add Button", "My Application",
MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
关于造成这种情况的任何想法?我已尝试删除代码,添加新消息并将其注释掉。