Sub ShowStockItems
' initialise a standard page viewer and add it to the main panel
svpStock.Initialize("svpStock",3,pnlStock.Width,pnlStock.Height-100)
pnlStock.AddView(svpStock.AsView,0,0,100%x,100%y)
' set in index to the first page
Dim iPanel As Int = 0
' create a panel array to contain details of each stock code
Dim P(15) As Panel
' panel size and positionaing variables
Dim iGap As Int = 15
Dim iPanelHeight As Int = 230
Dim iPanelWidth As Int = 406
Dim iPanelTop As Int = iGap
Dim iPanelLeft As Int = iGap
Dim iTop As Int = iPanelTop
Dim iLeft As Int = iPanelLeft
' display each stock item
For i = 0 To 14
' initialise the panel
P(i).Initialize("pStockPanel")
P(i).Tag=i
' add it to the view pager
svpStock.Panels(iPanel).AddView(P(i),iLeft,iTop,iPanelWidth,iPanelHeight)
' add a label to see which item this is
Dim lCode As Label
lCode.Initialize("")
lCode.TextSize=50
lCode.TextColor=Colors.Black
lCode.text = i
P(i).AddView(lCode,10dip,10dip,380dip,100dip)
' check to see if we are advancing horizontally, starting a new line or starting a new page
If (i+1) Mod 6 = 0 Then
' start a new page
iTop = iPanelTop
iLeft = iPanelLeft
iPanel = iPanel + 1
Else
If (i+1) Mod 3 = 0 Then
' start new row on current page
iTop = iTop + iPanelHeight + iGap
iLeft = iPanelLeft
Else
' position to next horizontal entry
iLeft = iLeft + iPanelWidth + iGap
End If
End If
Next
DoEvents
ProgressDialogHide()
End Sub