[英]How to check the datagridview not be empty?
I already tried this way but it is not working. 我已经尝试过这种方法,但是没有用。
How do I fix it? 我如何解决它?
if(dgvProducts.Rows.Count < 1 )
{
MessageBox.Show("Something");
return;
}
you may try something like this, 您可以尝试这样的事情,
if(dgvProducts.Rows.Count > 1 )
{
MessageBox.Show("Something");
return;
}
if it doesn't works then you may also try something like this too, 如果它不起作用,那么您也可以尝试类似的方法,
string nrCode = dataGridView1.Rows[0].Cells[6].Value.ToString();
nrCode = nrCode.Trim();
if (nrCode == string.Empty)
{
MessageBox.Show("there must be Entry in cell nrCode on first row.")
}
the above code will allow you to check if specific cell in first row in DataGridView is empty. 上面的代码将允许您检查DataGridView第一行中的特定单元格是否为空。
Hope it works. 希望它能工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.