Best Way to Manage and Store Container Properties

I’ve created a scrolling canvas of ContainerControl. My ContainerControl class consists of a TextField and a ComboBox. I have properties on the ContainerControl class such as ParentWindow and ParentScrollView.

Now I need an array to hold the ComboBox contents, and a property for the TextField and possibly others.

Is it best practice to just add a properties that I need for the TextField and ComboBox to the ContainerControl class? Or, is it best to create a new object that manages the properties I need for the TextField and ComboBox and then store a reference to that object as a property of the ContainerControl class?

Thank you

that depends really, if the instance will always hold the same values mostly unchanged then put them on the container

if you will need to load different sets of data into the container at runtime, then maybe a class would be better
and have a computed property or a method that you pass the class into to have the new values reflected.

or if the same data may be used by different controls then you could pass the same class to two different container controls
and have a different display.

you can always rewrite it later, once you decide the way you did it wasn’t quite right :smiley:

Thanks Russ. I will create the class. I am adding the ContainerControls dynamically to the Canvas using EmbedWithin.

The ContainerControl holds name value pair, where the combobox gives the user a choice of values to choose from. However, I would also would like create another ContainerControl that contains two TextFields (here, the combobox is not needed) so that the user can create his own name value pair. I would like to be able to add these two ContainerControls to the same Canvas.

So I have a method on the canvas that adds my first type of ContainerControl to the canvas.

[code]Sub AttributeCC_Add( theWindow As MyWin, theAttributeOccurrence As MyAttribOccurrence)
// Add the container to the scroll view canvas

// Create a new container and add it to the theScrollView (a Canvas)
dim oContainer as new MyAttributeCC( theWindow, self, theAttributeOccurrence )

// Add the newly created containter to the array of containers
// containers (aroContainers is an array on the window)
aroContainers.append oContainer

End Sub

Now, I would like to reuse this method for the second type of ContainerControl I want to create, but the array of containers I use here is an array of my first type of ContainerControl, so I can’t.

Is this where I need an interface? If so, can you point me in the right direction of implementing it?

Thank you

Just to close up this thread. I found a solution by creating a superclass from which then my two different ContainerControls were subclassed from. I then typed my array of containers to be that of the superclass.