C#DataGridView检查是否为空

Goo*_*ber 14 c# datagridview winforms

我有一个datagridview,它填充了linq查询返回的数据.如果查询没有返回任何结果,我想显示一个消息框.有没有办法检查datagridview是否为空?

问候

Met*_*ght 31

您可以通过检查DataGridView中的行数来确定它是否为空.如果 myDataGridView.Rows.Count == 0那么你的DataGridView是空的.