WebContainer embedWithin in a loop

Hi

Using Xojo 2024r1.1, I am getting this error adding WebContainers in a loop (7 containers). “Each WebContainer instance may only be embedded once”

I am instantiating each new WebContainer and setting the text to display, but it fails when embedding in the parent container.

Here is the section of code

var hc as new HorizontalContainer
hc.DateLabel.text = formattedDate
hc.ForecastLabel.text = forecastText
self.EmbedWithin(hc, 0, top, hc.Width, hc.Height)
top = top + hc.Height

This code is running in the ContentReceived event of a WebConnection.

Not sure what’s happening, what else I can try?

Here is the correction. Leaving here for others to learn from my mistake!

hc.EmbedWithin(self, 0, top, hc.Width, hc.Height)

1 Like