Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can i have one array per instance of a class
Message
From
09/05/2001 10:13:16
 
 
To
09/05/2001 00:14:58
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00505126
Message ID:
00505267
Views:
24
>I don't really understand variable/array scoping too well and need some help.
>
>I built a container class. The class has a combobox in it. (Actually 2 comboboxes). Then I inserted an instance of the class into each column of a 5 column grid. So now my grid has the container object instead of the default text, in each column.
>
>Now I want to use recordsource type of 5 - array, for the combobox. But this combobox gets instantiated about 30 times, once for each row/column in the grid. How can I get a unique array for each instance?
>
>Is it possible to have an array or array elements as properties of the form, or of the class? Is something like: thisform.grid1.column1.container.combobox.array[1].value='abcd' possible, or legal?
>
>In the past I have only made form properties as simple variables. If it is possible to make a property as an array, how would u declare it?
>
>Thanks.

Yes, you can have an array property, just add (1) or (1,1) to the end of the property name when you add it.
e.g., aSource(1,1)

Add this to the class itself, not to a potential parent container (like a form).
In your case, add it to the container, then set the combobox.RowSource="this.parent.aSource" or whatever the name of the array property is.

Also, have the class itself dimension and populate the array, not an external object. This keeps it encapsulated.

BTW thisform.grid1.column1.container.combobox.array[1].value='abcd' would only work if the array contained object references to objects that had a Value property.
Also, along these lines, I can't tell from your post if you are intending to this, but I would strongly encourage you to not get values directly from the array or the combobox.Value or DisplayValue properties, unless you do not have the combobox bound to a ControlSource. If you have a ControlSource, then you should get the value from that instead.

HTH
Insanity: Doing the same thing over and over and expecting different results.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform