3
我有一个程序,它从dataGridView中的选定行获取值并将其传递给函数。但是,gridView可能是空的或不能选择一行。 我照顾了空格,但我想知道是否有方法可以判断是否选择了任何行。我如何知道是否至少选择了一个dataGridView行c#
我尝试这样做:
if (Convert.ToInt32(dataGridView1.Rows.Count) > 0)
{
//It is not empty
}
int c = dataGridView1.SelectedRows.Count(); //this line gives me an error
if (c>0)
{
//there is a row selected
}
你知道我怎么能解决这个问题?
没关系,我想通了,这个问题在第二个“伯爵”感谢后括号。 –