Moving data from and to Containercontrol

I’m having a problem moving data from text field to a another text field in a containercontrol.
Following is code to load a containercontrol to pagepanels"

// panel 0
ccCGMain1 = New ccCGMain ’ left top
ccCGMain1.EmbedWithinPanel(ppCGGeneral,0,ccCGMenu1.Width,0)

// panel 1
ccCGName1 = New ccCGName
ccCGName1.EmbedWithinPanel(ppCGGeneral,1,139+ccCGMenu1.Width,0)

CCCGMain has a text field with a Text Change event, which has the code to move "me.Text
to tfName.text in the other panel.

I have tried different combation and I always get “This item does not exist”

I would think the following should work:

ccCGName1.tfCGName.text=me.text

But it does not. What am I doing wrong?

You need to propagate the TextChange event out to the window so you can put the code into the proper scope. Add an Event Definition to ccCGMain called TextChange, with a parameter “text as string”. Add a private method to ccCGMain named TextChange with the same parameter.

Sub TextChange(text as string)
   RaiseEvent TextChange(text)
End Sub

In the TextChange event of the TextField, call the TextChange method of the container.

TextChange(me.Text)

Finally, you need to use AddHandler when you embed ccCGMain1 to tie the event to a method on the window, where you can set the text of the other container.

Tim thanks for the try but>

I get the following error:

There are several items with the name and is is not clear which one the call refers to
TextChange(me.text)

Should I use an name other than “TextChange” like “myTextChange”

Not sure I understand the AddHandler.

Yeah, change the name of the method so it doesn’t conflict with the event definition.

To use AddHandler, create a method in the window

Sub HandleTextChange(cc as ccCGMain, text as string)
   ccCGName1.tfCGName.text = text
End Sub

Then before you embed ccCGMain1, call

AddHandler ccCGMain1.TextChange, addressOf(HandleTextChange)

Got an error on this:
AddHandler ccCGMain1.TextChange, addressOf(HandleTextChange)

change to:
AddHandler ccCGMain1.TextChange, addressOf HandleTextChange

also had to change 'myTextChange" to “myDataMove”

both “myTextChange” and “TextChange” were no no.

Now I get the error:
Type mistmatch error. Expected Delegete(ccCGMain.ccCGMain, String), but got Delegate(String)

Don’t understand this at all.

Did you add both parameters to HandleTextChange?

Yes. I put this in “Window” not in the panel or container. It’s “text as string”

You need both parameters, not just “text as string”.

That did it. Works. Don’t know why.

Thanks for putting up with me.

You’re welcome. AddHandler takes some getting used to. It needs a handle to the object that is firing the event, so Xojo adds that automatically as the first parameter to the method call, followed by the normal parameters of the event. So your method has to accommodate that by adding in a parameter that matches the type of object you are “handling”.