[英]How to check the datagridview not be empty?
我已经尝试过这种方法,但是没有用。
我如何解决它?
if(dgvProducts.Rows.Count < 1 )
{
MessageBox.Show("Something");
return;
}
您可以尝试这样的事情,
if(dgvProducts.Rows.Count > 1 )
{
MessageBox.Show("Something");
return;
}
如果它不起作用,那么您也可以尝试类似的方法,
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.")
}
上面的代码将允许您检查DataGridView第一行中的特定单元格是否为空。
希望它能工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.