IsA Container Control

I’m attempting to hide all newCC container controls in a window and then create a new one. Although I have several in the window the container controls are in none will hide or will reach the break. I would it’s my code that is a problem:
Index as integer is sent to this method.

[code]var newCC(6) As ContainerControl1
newCC(index) = new ContainerControl1
var i as integer

for i =(controlcount-1) downto 0
if control(i) isA ContainerControl1 then
break
newCC(i).hide
end
next i
newCC(index).EmbedWithin(Self, 50, 100)
[/code]

welcome to the wonderful world of container controls
they are a tad odd in that while you create a new instance of your specific container control when iteratiing the controls you have to look for EmbeddedWindowControl instances

var newCC(6) As ContainerControl1
newCC(index) = new ContainerControl1
var i as integer

for i =(controlcount-1) downto 0 
  if control(i) isA EmbeddedWindowControl then 
    break
    newCC(i).hide
  end
next i
newCC(index).EmbedWithin(Self, 50, 100)

[quote=494206:@Norman Palardy]welcome to the wonderful world of container controls
they are a tad odd in that while you create a new instance of your specific container control when iteratiing the controls you have to look for EmbeddedWindowControl instances

[code]
var newCC(6) As ContainerControl1
newCC(index) = new ContainerControl1
var i as integer

for i =(controlcount-1) downto 0
if control(i) isA EmbeddedWindowControl then
break
newCC(i).hide
end
next i
newCC(index).EmbedWithin(Self, 50, 100)

[/code][/quote]
Of course. Tough to be new green.

EmbeddedWindowControl did the trick but another problem came up. The second time you call this method an out of bounds. exception error occurs at newCC(i).hide. Maybe this will be oblivious to you.

your controlcount is bigger than your array.
you use i wrong.
maybe it is more control(i).hide

[quote=494208:@Markus Rauch]your controlcount is bigger than your array.
you use i wrong.[/quote]

I increased the array newCC(6) to newCC(100) but it still errored

[quote=494207:@Clifford Coulter]Of course. Tough to be new green.

EmbeddedWindowControl did the trick but another problem came up. The second time you call this method an out of bounds. exception error occurs at newCC(i).hide. Maybe this will be oblivious to you.[/quote]

tell me whats the intent of the newCC array ?
if its to track all instans then it should be a property of the window
and your code might then be

var newInstance As ContainerControl1
newInstance = new ContainerControl1

for i as integer = (controlcount-1) downto 0 
  if control(i) isA EmbeddedWindowControl then 
    break
    control(i).hide
  end
next i

newinstance.EmbedWithin(Self, 50, 100)
newCC.Append newinstance

[quote=494210:@Norman Palardy]tell me whats the intent of the newCC array ?
if its to track all instans then it should be a property of the window
and your code might then be

[code]
var newInstance As ContainerControl1
newInstance = new ContainerControl1

for i as integer = (controlcount-1) downto 0
if control(i) isA EmbeddedWindowControl then
break
control(i).hide
end
next i

newinstance.EmbedWithin(Self, 50, 100)
newCC.Append newinstance
[/code][/quote]

I wanted to see if it was feasible to create a window and populated it with a container control for each day of the week. These would be assigned to a control array property in the holding window. The data for that day would be stored in the day-specific container control. I’m trying to reason out how it could be put together. And you are correct newCC(6) was to track the array.

OK
So newCC should be a property of the window
That way the array will stick around until the window is closed

And then is this code is to create the one if it didnt exist before ?

I’m not sure how (newCC.Append newinstance ) works. Is it an array property that can keep tack of each of the 0-6 days of the week?

Actually I was thinking of creating all of them when opening the window, one for each day and hiding them when not needed. Maybe that’s not the best way to do it. I’m muddling through this. NewCC(index).EmbedWithin(Self, 50, 100) does created another but I will replace it with a show command when I figure out what that is.

I’m thinking maybe newCC.Append newinstance appends or grows an array. is that true?

In your example of the parent window owning the preference, how do you reference the days of the week to show and hide the days of the week if they are not indexed in some way? They would also need to be indexed in the preference array in the main window so they could be stored and loaded back in when the window opens again. ???

i would place your 7 cc in the window.
at window open put them in your property which is an array. there you can also set the position at the window if needed.
if you will hide them all use for each with your property / array.
if you will show one use date day of week as index for your property / array.

Where do you initialise controlcount?

[quote=494221:@Markus Rauch]i would place your 7 cc in the window.
at window open put them in your property which is an array. there you can also set the position at the window if needed.
if you will hide them all use for each with your property / array.
if you will show one use date day of week as index for your property / array.[/quote]

When it was done Markus I did not need a reference to keep track. It was amazingly simple to code overall, well with a little help learning how to pass the array(,). I though multidimensional arrays needed to be in a wrapper class to be passed. Not so.