I have a small ContainerControl (160x143) called groupCtr which contains just a couple of other controls. I need to place 15 of these CC’s on my window. I have created a window-scoped property (cc As groupCtr). In a loop I can create the CC’s by
for i As integer = 0 to 14
cc = New groupCtr(i)
cc.embedWithin(Self, x, y)
next
The passed param is to create an index property in the CC’s constructor.
OK great! Now. I will need to put data into various of these CC’s as the program progresses.
How do I identify the CC. Say I want to put someData As String in cc #6. Since I could not create an array of these containers, do I have to poll the entire list of CC’s looking for the one with index #6 each time I want to do something with one of them?
How do I identify each of these 15 cc’s on my window?
Thank you, Anthony, for your reply. Something got messed up with this thread and I didn’t see you response until now.
for i As integer = 0 to 14
dim newCC as ContainerControl = New groupCtr(i)
newCC.embedWithin(Self, x, y)
cc.Append( newCC ) //runtime error "Parameters are not compatible with this function
next
The issue is that you can’t make an array of container controls
That’s what I was bumping up against before.
Thank you Anthony and Tim. I keep getting compiler errors when I try cc() As ContainerControl and I thought I had read somewhere that CC’s could not be arrays, so I may have jumped to conclusions. I will try to digest your advice and make this work.
Thanks again for your help
As a quick test, I created a container, GroupCtr. I added a property to the window, cc() as GroupCtr. In Window.Open, i put:
dim newCC as GroupCtr
newCC = new GroupCtr
cc.Append newCC
Runs without error. If all the containers in the array are the same type, then make the array that type and it will make your code easier. You can do things like
cc(10).someCustomMethod
dim i as integer = cc(10).myCoolIntegerProperty
for i = 0 to ubound(cc)
if cc(i).ID = 5 then
...
end
next
ContainerControls are really just like any other class/object.
[quote=381806:@Roger Clary]Thank you Anthony and Tim. I keep getting compiler errors when I try cc() As ContainerControl and I thought I had read somewhere that CC’s could not be arrays, so I may have jumped to conclusions. I will try to digest your advice and make this work.
Thanks again for your help[/quote]
I think the limitation you’re remembering is that you cannot (or could not in the past, not sure about now) make a ControlSet (fka ControlArray) of ContainerControls.
With your last example, Tim, I think I’ve got it to where I can make this work.
Thanks again to all who responded. I’m really appreciating this forum tonight
With your last example, Tim, I think I’ve got it to where I can make this work.
Thanks again to all who responded. I’m really appreciating this forum tonight