在VB.NET中如何检查gridview中的特定列是空的? [英] How to check specific column in gridview is empty in VB.NET?
本文介绍了在VB.NET中如何检查gridview中的特定列是空的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有列empID,日期,CheckIn时间,结帐时间,电话。
如果checkintime为空,我只需要显示一个按钮(签入),
如果结账时是空的,我必须只显示结账按钮。
如果两者都有值,我必须禁用两个按钮。
我尝试过:
I have the columns empID,Date,CheckIn time,Checkout Time,phone.
If checkintime is empty i have to display only one button(checkin),
if checkout is empty i have to display only checkout button.
if both has values i have to disable both buttons.
What I have tried:
If GridView1.Columns.Count > 0 Then
Button1.Visible = False
Else
Button1.Visible = True
End If
推荐答案
可能是这样的:
It could be something like this :
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If e.RowIndex >= 0 Then
Dim myCell As Object
myCell = DataGridView1.Rows(e.RowIndex).Cells(2).Value
If myCell IsNot Nothing Then
If myCell.ToString.Trim <> "" Then ButtonCheckIn.Visible = True
End If
myCell = DataGridView1.Rows(e.RowIndex).Cells(3).Value
If myCell IsNot Nothing Then
If myCell.ToString.Trim <> "" Then ButtonCheckout.Visible = True
End If
End If
End Sub
默认情况下按钮应为Visible = False
By default both Buttons should be Visible = False
这篇关于在VB.NET中如何检查gridview中的特定列是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文