Page 1
Page 2
In most applications, we can come up
with a definitive set of controls and place them on a form
to give the user all of the flexibility they could possibly
need. There are, however, other situations in which we don't
know how many controls need to be placed on a form until
the program is actually running. This presents a problem
for eVB developers (particularly because some of the most
useful Pocket PC software involved user-defined lists of
one sort or another). In this article, I will present a
straight-forward solution to this problem.
Please note that for efficiency and
readability purposes, the following technique incorporates
the use of "simulated
control arrays" as described in my previous article.
If you have not yet read that article, I recommend skimming
over it before continuing with this one.
The key to this solution is taking
advantage of the fact that all Pocket PC devices have the
same screen resolution. Because of this, we know that the
number of controls that can be visible on a form is constant
(though it will vary from one application to another based
on the type of controls, size of the controls, and vertical
spacing between them).

For the purposes of this demo, we will
create an application that prompts the user for a number
and then "displays" that many checkboxes. We'll
keep the interface simple and use a single column of 8 checkbox
controls spaced evenly down a form.
Now, with the addition of a vertical
scroll bar (named Scroll) to our form, these 8 checkboxes
can be used to give the illusion of having an infinite number
of them. The general idea of this "illusion" is
that the number of controls on the screen does not change,
but as the user moves the scroll bar, we will alter which
of the controls are visible and what the displayed captions/values
are.
Once you've setup your user interface,
the first step is to build a simulated control array out
of the 8 checkboxes (this code is explained in my
previous article):
' Fake control array
Dim Check(7) As CheckBox
' Pass event handling off to a central
function
Private Sub Check0_Click()
Check_Click 0
End Sub
Private Sub Check1_Click()
Check_Click 1
End Sub
Private Sub Check2_Click()
Check_Click 2
End Sub
Private Sub Check3_Click()
Check_Click 3
End Sub
Private Sub Check4_Click()
Check_Click 4
End Sub
Private Sub Check5_Click()
Check_Click 5
End Sub
Private Sub Check6_Click()
Check_Click 6
End Sub
Private Sub Check7_Click()
Check_Click 7
End Sub
Next Page