【发布时间】:2016-08-23 15:56:42
【问题描述】:
我正在尝试通过函数计算 datagridview 中填充的行数。
此函数包含 2 个参数,第一个是我要填充的列数,第二个是 datagridview 的行数。
我试过这段代码:
Function dgvAggregate(ByVal colNum As Integer, ByVal dgvcount As Integer)
Dim x As Integer = 0
For i As Integer = 0 To dgvcount - 1
For j As Integer = 0 To colNum
If Not (dg.Rows(i).Cells(j).Value = Nothing) Then
x += 1
End If
Next j
Next i
Return x
End Function
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
MsgBox(dgvAggregate(2, dg.Rows.Count))
End Sub
但此代码返回具有值的单元格的数量!
如何根据用户输入的列数仅计算行数?
【问题讨论】:
标签: vb.net datagridview