目前,我有以下几点:
if (dataGridView1.Rows.Count == 0)
{
    MessageBox.Show("EMPTY");
}
else
{
    using (var soundPlayer = new SoundPlayer(@"c:\Windows\Media\chimes.wav"))
    {
        soundPlayer.Play(); // can also use soundPlayer.PlaySync()
    }
}我的网格视图如下所示:

但它似乎是去其他的陈述,并发出声音。如果网格视图的行中没有数据,我需要它不发出声音。
发布于 2013-08-23 07:56:01
根据评论,你有:
dataGridView1.DataSource = BS;其中BS是BindingSource,所以您可以使用它的BindingSource.Count属性。
所以在代码中的某个地方:
var bindingSource = dataGridView1.DataSource as BindingSource; 
if(bindingSource.Count == 0) {
  MessageBox.Show("EMPTY");
}https://stackoverflow.com/questions/18397586
复制相似问题