PagePanel don't exist error

Hi,
Im trying to address a page in PagePanel1 trough a mouse down-event outside the panel, but in same Window. Xojo says PagePanel1 don’t exist and stop. I disagree strongly :slight_smile: Whats wrong here? Image shows what I do…

You need to raise an event from that Container Control and implement an Event Handler on C_menyfelt1 to change the PagePanel.

1 Like

You are wrong :stuck_out_tongue_winking_eye:

The event is NOT in the same window. The MouseDown event happens inside a C_Menyfelt, and as Xojo says, PagePanel1 don’t exist there.

That container can be placed on ANY window or other container, the compiler cant guess that you are going to use it in a Win_Hoved.

Adding an event as raising it as Tim said is the propper option but you can do it directly like:

Dim Win_HovedInstance As Win_Hoved = Win_Hoved(Self.TrueWindow)
Win_HovedInstance.PagePanel1.Value = 0

That way you get the parent of the container, cast it to type Win_Hoved and access the PagePanel1 directly

However, this will fail and cause an error if you put the container in other parent that is not a Win_Hoved.

Thanks Ivan and Tim, worked as a breeze - and I just learned something. :+1: