Panel:SizeToChildren()/Panel:ChildrenSize() not behaving correctly?


local info = vgui.Create("DCollapsibleCategory", frame)
	info:Dock(TOP)
	info:SetLabel("Information")
		local p = vgui.Create("DPanel", info)
		p:DockPadding(10, 5, 10, 5)
			local own = vgui.Create("DLabel", p)
			own:SetText("Owner: " .. tostring(owner))
			own:SetDark(true)
			own:Dock(TOP)
			local co = vgui.Create("DLabel", p)
			co:SetText("Co-owners: ")
			co:SetDark(true)
			co:Dock(TOP)
			for i = 1, 10 do
				local a = vgui.Create("DLabel", p)
				a:SetText(i)
				a:SetDark(true)
				a:Dock(TOP)
			end
		print(p:ChildrenSize())
		p:SetSize(0, 300)
		p:Dock(TOP)
		print(p:ChildrenSize())


74	25
74	25


Why is ChildrenSize returning something that’s obvously not correct?

The panel doesn’tcall perform layout until the next frame, try running p:InvalidateLayout( true ) immediately before.