VB 10:如何检查datagridview单元格中的空值 [英] VB 10 : how to check null value in datagridview cells

查看:245
本文介绍了VB 10:如何检查datagridview单元格中的空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试/检查数据gridview中的单元格是否为空,单击时显示单元格中有空数据的标签,谢谢之前



 如果 dgvdatakaryawan.Item(e.ColumnIndex,e.RowIndex).Value.ToString.Length =  Nothing  然后 
lblKET.Visible = True
其他
lblKET.Visible = False
结束 如果





i意味着我有很多数据,如果在一行中有一些空白数据,并且当点击行时它显示如上所示的标签

解决方案

我认为你的如果语句应如下所示。如果单元格为空或仅包含空格或空字符串,则将 lblKET 设置为可见。





 如果 dgvdatakaryawan.Item(e.ColumnIndex,e.RowIndex).Value    Nothing   orelse  _ 
dgvdatakaryawan.Item(e。 ColumnIndex,e.RowIndex).Value.ToString.Trim = 然后
lblKET.Visible = True
其他
lblKET.Visible = False
结束 如果


hi, i want to test/check when cells in data gridview is empty and when clicked it shows label like "there's a empty data in cell", thanks before

If dgvdatakaryawan.Item(e.ColumnIndex, e.RowIndex).Value.ToString.Length = Nothing Then
           lblKET.Visible = True
       Else
           lblKET.Visible = False
       End If



i mean i have lot of data, if in one rows have some blank data, and when rows is clicked it show label like above

解决方案

I think your If statement should look like this. It sets the lblKET to visible if the cell is Null or contains only spaces or an empty string.


If dgvdatakaryawan.Item(e.ColumnIndex, e.RowIndex).Value Is Nothing orelse _
   dgvdatakaryawan.Item(e.ColumnIndex, e.RowIndex).Value.ToString.Trim = "" Then
     lblKET.Visible = True
Else
     lblKET.Visible = False
End If


这篇关于VB 10:如何检查datagridview单元格中的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆