更新时间:2023-12-06 13:16:28
您需要检查 DataGridViewCell 的 Value 属性是否为null或所以你可以这样做:
You need to check if the Value property of the DataGridViewCell is null or not.So you can do something like:
Public Function IsDataGridViewEmpty(ByRef dataGridView As DataGridView) As Boolean
Dim isEmpty As Boolean
isEmpty = True
For Each row As DataGridViewRow In dataGridView.Rows
For Each cell As DataGridViewCell In row.Cells
If Not String.IsNullOrEmpty(cell.Value) Then
' Check if the string only consists of spaces
If Not String.IsNullOrEmpty(Trim(cell.Value.ToString())) Then
isEmpty = False
Exit For
End If
End If
Next
Next
Return isEmpty
End Function
或,可以查看..
http://social.msdn.microsoft.com/Forums/en-US/0fa5f291-35d2- 4ecf-afb1-9f52ab959109 / data-grid-in-vbnet [ ^ ]
Or, can view..
http://social.msdn.microsoft.com/Forums/en-US/0fa5f291-35d2-4ecf-afb1-9f52ab959109/data-grid-in-vbnet[^]
然后你需要在搜索按钮上写下这段代码搜索过程
then you need to write this code on your search button after the search process
If DataGridView1.RowCount > 0 Then
btnSave.Enabled = True
Else
btnSave.Enabled = False
End If