Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Collection class clarification
Message
From
19/05/2003 22:42:27
F Bilo
Bilo Office
Fuyang, China
 
 
To
06/05/2003 14:04:56
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00785502
Message ID:
00790259
Views:
18
I got a question like this too, but what i used wasn't a form collection, but a buttons collection in a container.like this:

container.init:
___________________________________________
this.buttons = newobject("Collection")
___________________________________________


Container.addbutton:
___________________________________________
LPARAMETERS ckey

LOCAL nCount

nCount = this.buttons.count

** check wether this button have exist
IF TYPE("This.But_"+ cKey) = "O" AND !ISNULL(EVALUATE("This.But_" + cKey))
RETURN
ENDIF

** Add button object
this.AddObject("But_" + cKey, "CommandButton")

** Add the button's ref to collection
this.buttons.add(EVALUATE("this.But_" + cKey), ckey)

With this.buttons.item(ckey)
.caption = ckey
.visible = .T.
endwith
___________________________________________

Container.clear
___________________________________________
local ncount as integer, n as integer
nCount = this.buttons.count
for m.n = nCount to 1 step -1
this.buttons.remove(m.n)
endfor
___________________________________________

In this way, I got several question:

first, i call the container.clear in form's release event, but if i click the form's close button, it's seems the release event will not been fire, i must add 'thisform.release' to form's queryunload events to solve this.

Second, i found that if i use container.removeobject('buttonname'), the ref in collection will be remove automatic also, but not work conversely.

third, if i directly use the collection's add method to create a new button, then you can't see the button anywhere ,even you set the button's visible = .t.. you must add the button to a container, then add ref to collection like i do.And even in my way, Sometimes the buttons will not visible occasional, you must set the visible = .T. again!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform