Hi,
i'm developing an application for pocket pc.
In this application I have a number of screens that I build dynamically according to database records.
I have the following code:
VB Code:
' Global ' Controls for screen A Private ar_pcbThemaButtons() As PictureBox ' Controls for screen B Private ar_pnlSubThemaButtons() As Panel Private ar_pcbSubThemaButtons() As PictureBox Private ar_lblSubThemaButtons() As Label ' Controls for Screen C Private ar_pnlObjektenButtons() As Panel Private ar_pcbObjektenButtons() As PictureBox Private ar_lblObjektenButtons() As Label Private sub getScreenA() ClearPreviousScreen() ... ar_data = getFromDB() Dim i as integer redim ar_pcbThemaButtons(ar_data.length - 1) For i = 0 to ar_data.length - 1 ar_pcbThemaButtons(i) = new PictureBox ' Set Props for ThemaButton (Image, size, location) ..... pnlButtonHolder.Controls.add(ar_pcbThemaButtons(i) Next End Sub
For screen B and C is that the same thing except that I use a
panel, picturebox and label for them.
Now between switching the screens I do a ClearPreviousScreen().
So in the ClearPreviousScreen I dispose of the controls that I don'tVB Code:
Private sub ClearPreviousScreen() Dim oCtrl as Control For each oCtrl in me.controls ' This is the place where it goes wrong oCtrl.visible = false next dim i as integer if ScreenA then for i = 0 to ar_pcbThemaButtons.length - 1 if not ar_pcbThemaButtons(i) is nothing then ar_pcbThemaButtons(i).dispose() 'Remove the control end if next end if End Sub
need anymore.
This works for a while until the app exists without an error message. (At the point where I
start my loop through the me.Controls collection. )
Is my way of working incorrect?????
I can't seem to figure out what I'm doing wrong.
If I don't use the dispose on the array of controls the application doesn't exit.
But this results after a while in an out of memory error.
Could somebody help me out here?
Regards,
Steve




Reply With Quote