ContainerControl move problem

This should be so trivial … but I can’t find the error I must be producing.
Problem is this: I use containercontrols embedded in a canvas for a statistics window:

The disclosure triangles attach an additional container with extended information. When they do, the window is resized to the new height (as well as the canvas) and the remaining containers (which have been added programmatically and are kept alive in an array) are moved down the height of one container.
Both container types have a height of 80 points.

As you can see, the “alle” container is not visible anymore.

And if I open the window from scratch and try to attach an extension to the second container, it results in this:

The code of the disclosure triangle action event handler (I restructured it already to make it verbose – before it was all in a loop) is this. When I try to open the second extension, Pos is correctly 1 and the y position it should attach the new container at is 160 – which is correct. The program results in an increasing offset, which means opening the extension for the third container gives two blank rows below it.

[code]Sub Action()
dim containers() as FieldStatContainer = StatsWindow(me.Parent.Window).Containers
dim count as integer = Containers.Ubound // here the containers are kept alive, in a property of the parent window
dim pos as integer
for q as integer = 0 to count // Finding out what position the container where the triangle was clicked has
dim fc as FieldStatContainer = containers(q)
if fc= self then
pos = q // saving the position in this variable
exit for
end if
next

if me.Value then
Extension= new FieldStatExtensionContainer(BestellteHalbParz, PercentageHalbParz, BestellteParzellen, PercentageParz, NumNew, NumKeep, NumChange, NumIncrease, _
Gesamtforderung - Gesamtrabatt - Gesamtzahlungen) // I create a new extension container which is a property of the parent container

system.debuglog "Pos: "+pos.ToText+"  Count: "+count.ToText // everything comes out as expected
system.DebugLog Extension.Height.ToText // and the height is 80 (I suspected a HiDPI problem but it doesn’t look so.
me.parent.Window.Height = me.parent.window.height + Extension.Height // resizing the parent window
me.Parent.Height = me.parent.Height +Extension.Height // and the parent canvas as well
for p as integer = count downto pos+1
  Containers(p).Top = containers(p).top + Extension.Height // moving down the rest of the containers for 80 pixels.
  // afterwards, the last container is missing
next
dim newtop as integer = (pos+1)*Extension.Height // The y position for the extension container. Ok too: 80 for the first, 160 for the second …
System.DebugLog (newtop.ToText)
Extension.EmbedWithin(me.Parent, 0, newtop) // but it is attached with an increasing offset.

else
if Extension <> nil then
Extension.Close
extension = nil
// move others up! // not yet implemented
end if
end if
End Sub[/code]

I am almost certain I made a very stupid mistake, but it seems to be one of those days …

Found a solution. If someone can give me a hint why this works, please do! I don’t have any:

– made the canvas autoresize to full autoresize with the window, removed canvas height change
– changed the embed command to

Extension.EmbedWithin(me.Parent, 0, Extension.Height) // why is that ok?

I don’t know but because Extension.Height (which is always 80) works then it seems to be relative to the expanding row. So maybe me.Parent isn’t what you think it is. Try logging the parent name and see if it’s the expected Canvas.

system.debuglog "me.Parent.Name = " + me.Parent.Name

It’s so good to find out that you were right from the start: Yes, I had been doing something really stupid. When you start a method on window instance level and then move it to an action event for a control that rests on that window, “me” becomes someone else of course. :wink:
But as written: It obviously was one of those days. Thanks Will, you found it!