Moving controls throws "child cannot be Nil” exception

Hi,

I’m trying to understand a runtime exception: I’d like to reparent a control but I’m getting an “child cannot be Nil” error. Code in Opening event:

Dim canvas As MobileCanvas = New MobileCanvas

Self.RemoveControl(Button1)
Self.AddControl(canvas)

canvas.AddControl(Button1) // Exception: child cannot be Nil.

My test project is very simple:

image

Thank you,
John

Does this work for you?

Var b As MobileButton = Button1

Self.RemoveControl(Button1)
Self.AddControl(canvas)

canvas.AddControl(b)
1 Like

Yes, thank you. That makes sense, of course. The reference to Button1 was gone.