Re: Number of rows in a datagrid
- From: "Mark J. McGinty" <mmcginty@xxxxxxxxxxxxxxx>
- Date: Sat, 8 Oct 2005 01:52:15 -0700
"PaulNaude" <PaulNaude@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E2438D9F-3085-4780-B67D-F9D48592410D@xxxxxxxxxxxxxxxx
>I discovered the hard way that the property "VisibleRowCount" of a datagrid
> is ONLY that, the number of visible rows, NOT the number of populated rows
> in
> the datagrid.
>
> I need the number of populated rows (i.e. the number of records the user
> has
> access to by scrolling to the end of the list).
>
> I can't get it from the table since the datagrid is filtered.
>
> Should I actually run a for next loop to count the rows, or even create a
> datatable from the datagrid?
>
> I am sure there must be a short cut!
Obtain a reference to the recordset object to which the grid is bound, and
query its RecordCount property.
' assumes datagrid object is named 'Grid'
'
Dim rs As ADODB.Recordset
Dim obj As Object
Set obj = Grid.DataSource
If (Not IsEmpty(Grid.DataMember)) And (Grid.DataMember <> "") Then
Set rs = obj.DataSource
Else
Set rs = obj
End If
Dim NumOfRowsInGrid
NumOfRowsInGrid = rs.RecordCount
' Don't close the recordset, it's a reference to the one to which the
grid is bound
Set rs = Nothing
-Mark
.
- Follow-Ups:
- Re: Number of rows in a datagrid
- From: alekmice
- Re: Number of rows in a datagrid
- Prev by Date: Re: arggggg... adodb.connection error... help
- Next by Date: ADOX modify column Nullable
- Previous by thread: arggggg... adodb.connection error... help
- Next by thread: Re: Number of rows in a datagrid
- Index(es):
Relevant Pages
|
|