private void statesListBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
//Select a state to remove from list box
if (statesListBox.SelectedItem != null)
return;
if (statesListBox.SelectedItem.ToString().Length != 0)
{
if (
MessageBox.Show("Are you sure you want to delete " +
statesListBox.SelectedItem.ToString() + "?", "Delete"
+ statesListBox.SelectedItem.ToString(),
MessageBoxButtons.YesNo, MessageBoxIcon.Information)
== DialogResult.Yes
)
statesListBox.Items.Remove(statesListBox.SelectedItem);
}
}
首先第一件事情。
当按下“是”时,上面的代码会删除您选择的项目。既然你在问一个问题,那就是为什么答案可以是和否的形式。
其次根据您对RJLohan answer给出的评论(Any idea what is causing the overload error when I try adding the exclamation icon to my message box? I believe it is a error caused by the toString
),有一个过载错误。经过一番思考我想我已经得到了,为什么,什么错误,您正在服用约
您必须调用MessageBox.Show
为
MessageBox.Show Method (String, String, MessageBoxIcon)
而right syntax是
MessageBox.Show Method (String, String, MessageBoxButtons, MessageBoxIcon)
这就是为什么必须将错误说法"The best overload method match for 'System.Windows.Forms.MessageBox.Show(string, string, System.Windows.MessageBoxButtons)' has some invalid arguments."
或类似的东西。
这是Winforms还是WPF? – Steve