Checking if object already initialized

hbs

New Member
Licensed User
Longtime User
I'm having issues with a Windows Mobile app using several forms and an SQLite database.
I have a product details form which navigates to a product search form with a Listview control.

Everything works fine the first time I show the form, but the Listview control does not seem to refresh on subsequent searches (close form and then show again).

The problem is when I initialize the listview in the form.show event.
B4X:
Sub frmSearch_Show

    lvSearch.New1("frmSearch",0,50,240,110)       
    lvSearch.FullRowSelect=True
    coltype.New1
    lvSearch.AddColumn("Code",75,0,True,coltype.NText)
    lvSearch.AddColumn("Description",100,0,True,colt
End Sub

The second time I show the form it creates another instance, since the form itself is not destroyed when closing (only hidden).
I know could move the code to initialize all objects/controls needed in my app_start sub, but since the app may grow to many forms, I don't know if this is the best way.

Is there a way I can check if an object is initialized before creating it, so I don't create a second instance?

Any advice would be appreciated.

Peter
 

JonPM

Well-Known Member
Licensed User
Longtime User
You can track it yourself by creating a new variable, lvIsInitialized = False, then set to true when you initialize it.
 

Cableguy

Expert
Licensed User
Longtime User
You can also use the .tag property and use it as a flag
 
Top