Page 1
Page 2
Page 3
[Editor's note:] The day after the Pete's
last
article on the performance grid article was published,
we were contacted by Odyssey Software asking if we wanted
to test their virtual list view. What better person to review
Odyssey's new (and free) control than the grid performance
guru himself - Pete Vickers. Download
this article's sample code and also check out Odyssey
Software Developer Web Site. If you do contact Odyssey
please mention this article. [Editor's note:]
Introduction
Odyssey are providing this control FREE
to the developer community, and ROYALTY FREE distribution.
As a software developer who buys controls, that is the kind
of price I like. Then again, as a software developer who
sells controls, I don't like the precedent. I think it is
great of Odyssey to donate this control. This article will
put it through its paces, and see if it is better than the
grid, or normal listview.
I probably approached this from
a jaundiced point of view, as I am a grizzled old developer,
who generally has no truck with these newfangled 'bound'
or virtual controls. They make the job too easy
- what is wrong with coding absolutely everything? Still,
pushing aside my prejudices, away we go.
To quote from Odyssey...
"The DataViewer is very fast and much better than a
regular ListView, Grid, or ComboBox. Especially the ComboBox
because you can display multiple columns with column headings
in the simulated combo (scrolling both vertically &
horizontally), yet you can choose what column to return
to the TextBox (used to hold the selection) when the user
selects a record from the list. The main principal behind
the DataViewer is that you are not loading up the control
with a copy of your data, which the control then displays.
Instead, you tell the control that you have data (and how
much) and it will then ask you ONLY for the data it needs
for the current viewport (displayable area of the DataViewer).
So, it is really a virtual ListView control (report mode
only). That is why the rendering speed of your data is always
the same (typically < 1 sec.), regardless of the amount
of data you have whether its 1 row or 100,000 rows.
This allows you to pull and display
data directly from the data source (in most cases an ADOCE.Recordset)
without loading a copy of the data in into the control (much
more memory efficient and of course must faster)."
This fits in with what people have done
with the grid control in the past, i.e. 'page' records.
I received a sample application from
Odyssey, and used that as a test to see how easy the control
was to use. I then developed an application (two as it turned
out) from scratch, to gauge it from how easy it was to integrate
into an application. Their sample used the northwind database.
I decided to build a simple test database from scratch,
and allow the developer to populate it with as many (or
few) records as he liked, to test out the performance. This
also allowed the sample application to demonstrate the use
of Menus, and a simple progress bar. I also decided to add
a simple edit facility.
The design of the form finished up as
this:

The application would therefore allow
us to:
- Browse Records
- Show a Tap and Hold
- Respond to Tap and Hold
- Retrieve records using 'movenext'
- Retrieve records using getrows
Our menu has 4 items under the database
menu:
- Drop the database
- Create the database
- Create the table
- Populate the table
In addition, we have an 'options' menu
that will allow us to choose whether to use 'getrows' or
movenext.
The real engine of the DataViewer is
in the 'GetItemText', and is the one that is probably the
most difficult to get your head around (it was for me, but
hey, the brain cells are now dying rapidly!). The 'GetItemText'
is much dependent on the rowcount property.
Effectively, we set the .rowcount to
the number of the records in the recordset. We then give
the dataview control the focus. This fires the 'GetItemText'
event, passing in the row and column to popuplate...
Private Sub dvRecs_GetItemText(ByVal Row
As Long _
, ByVal Column As Long, Text As Variant)
So, the very first time in, we are sent
row = 1, column = 1. We then need to populate the 'text'.
This is done here by a 'general' subroutine...
Text = CStr(GetRecordsetFieldValue _
(rs, Row, Column))
Private Function GetRecordsetFieldValue
_
(rsSet As ADOCE.Recordset, _
lngRow As Long, lngColumn As Long) _
As Variant
If Not (rsSet.BOF And rsRecordset.EOF) Then
If Not rsSet.AbsolutePosition = lngRow Then
rsSet.Move (lngRow - rsSet.AbsolutePosition)
End If
If IsNull(rsSet(lngColumn - 1).Value) Then
GetRecordsetFieldValue = "(null)"
Else
GetRecordsetFieldValue = _
rsSet(lngColumn - 1).Value
End If
Else
GetRecordsetFieldValue = ""
End If
End Function
Next Page