The module that creates this window also embeds in this window a ContainerControl (ccCounters), containing a PushButton and several TextFields
dim ccCtrs As new ccCounters
ccCtrs.EmbedWithin(w,0,0,w.Width,15)
The same module wants to address a TextField in the ContainerControl
So I try
w.ccCtrs.Textfield(3).BackColor = &cFFDBB700
But this doesn’t work. (scope of the controls = public)
Probably I have a blackout… but
Why doesn’t it work and what is the right way to do this.
Store a reference of the container in a variable of type ccCounters in the window. Say, make it myCounters and then after you create the new instance of the container set myCounters = ccCtrs
Then, when you want to access the contents you could say:
w.myCounters.Textfield(3).BackColor = &cFFDBB700
w.ccCtr.TextField(3) is not valid. “TextField” is not a possible instance name of a TextField. And TextField(3) would mean that you have a ControlSet of text fields. Is that the case?
If you look at the image I included you will see a Pushbutton which is not part of a controlset.
He doesn’t see that either http://screencast.com/t/RiXiAlkRwe9
Re-reading your initial post, I’d say you have an issue with the window. You write that you create the window like that:
dim w as window1 = new Window1
This means that you will not have access to the window outside of the method where this code is located. w should be a property of your module (or App), which you then set like that:
w = new Window1
Another thing: if you have code like:
w.ccCtr.TextField(3).BackColor = &cFFDBB700
… you always should test for Nil first:
If w Is Nil Then
// error
End
If w.ccCtr Is Nil Then
// error
End
w.ccCtr.TextField(3).BackColor = &cFFDBB700
If w is not Nil and ccCtr is not Nil your code will work.