Control a container via code

Hi having a container embeedded into my main window, how do I from a pushbuttons action in that window control controls that are in the container…

I.e. buttons action tells labels in the containers to change text…

trying to:
cc2.label1.text = “new text” results in items does not exist

cc2 has been dimmed as new cc

All works as far as showing up in my window, but changing the properties of a control, I can not do… Why ?

[quote=132992:@Helge Tjelta]Hi having a container embeedded into my main window, how do I from a pushbuttons action in that window control controls that are in the container…

I.e. buttons action tells labels in the containers to change text…

trying to:
cc2.label1.text = “new text” results in items does not exist

cc2 has been dimmed as new cc

All works as far as showing up in my window, but changing the properties of a control, I can not do… Why ?[/quote]

1 - Mac, Windows, Web (probably) ?
2 - Post your code…

From window1 open event:
Dim cc3 as new cc1 // cc1 is the name of container
cc3.EmbedWithin(self)
Dim cc2 as new cc2 // cc2 is the name of container
cc2.EmbedWithin(self, me.width-cc2.width,0, -1,-1)
cc2.LockLeft = FALSE
cc2.Lockright = TRUE

cc11.lbl1.text = “Nami” // this is a controller in a container added to the window via IDE and this works…

From pushbutton acton (pushbutton is a controller in window1
cc11.Lbl1.text = TextField1.text + “cc11”

cc2.Label1.Text = “Helge”

cc2.Label1.text = TextField1.text + “cc2”
cc3.Lbl1.text = TextField1.text + “cc3”

I looked at the content of the window through Window.Control() and neither CC2 nor CC3 show. Neither does a Container Control dragged over the window.

But I can see

_Window1._wrapper_CC _Window1._wrapper_CC11

Not too sure what to do at this point. I know Container Controls are not real controls anyway…

It looks like you declared cc2 and cc3 in the Window Open event handler, but are trying to access them in a completely separate button event handler. Those variables are not in scope for the button event handler, which is why you get “item does not exist”.

Make them properties of the Window instead and you’ll be able to access them in both places.