如果所选行为 0,我想显示消息“您尚未选择任何行”。
但是,即使我单击 datagridview 中的第一行并跟踪它,所选行总是给我 0。
为什么会这样?
这是代码:
MessageBox.Show(dataGridView1.SelectedRows.Count.ToString()); // below function always run, because the selected rows always 0, even i clicked the first row in datagridview (when run the program)
if (dataGridView1.SelectedRows.Count == 0)
{
if (choice.comboBox1.Text == "English")
{
System.Media.SoundPlayer sound = new System.Media.SoundPlayer(@"C:\Windows\Media\Windows Exclamation.wav");
sound.Play();
MessageBox.Show("You Have Not Selected Any Rows!", "Error");
}
}
else
{
DeleteDatabase(sender, e);
}