[RESOLVED] Rowcount particular value
Hi vbforum users!
I need to rowcount in datagridview with a particular value.
My column "6" have the value that find, I try with the following code:
Code:
Dim apc As Decimal = 0
For x As Integer = 0 To DataGridView3.RowCount - 1
If DataGridView3.Rows(x).Cells(6).Value = "AP" Then
apc = DataGridView3.Rows(x).Cells(6).Value.ToString.Count
End If
Next
textbox1.text=apc
any help, as welcome!!:thumb:
Best Regards!!
Re: Rowcount particular value
Are you trying to get the sum of the values in column 6, or just the count of the number of rows that have the given value?
If the former, then the line above would look like:
vb Code:
apc += DataGridView3.Rows(x).Cells(6).Value
If the latter, then you would simply say:
Re: Rowcount particular value
Great Dolot! Best Regards!
Code:
For x = 0 To DataGridView3.Rows.Count - 1
If DataGridView3.Rows(x).Cells(6).Value = "AP" Then
count += 1
End If
Next
Re: Rowcount particular value
How exactly is the datagridview being populated? Is there a datatable attached to it, or is it just user input?
Re: Rowcount particular value
Hi Sr!
Only populate the textbox :)
Code:
For x = 0 To DataGridView3.Rows.Count - 1
If DataGridView3.Rows(x).Cells(6).Value = "AP" Then
count += 1
End If
Next
textbox1.text=count