Auto positioning DCollapsibleCatagories

How would I go about getting DCollapsibleCategories to automatically position? For example if I had 2 categories, expanded, and I close the top one, how do I get the one on bottom to fill the space?

(I posted in problems that don’t need their own thread, but got no response for 24 hours, and my post has since been lost in a sea of new posts. Sorry for resorting to making a new thread.)

This is what they do as of now:


If it is just setting visibility, make sure you change size to 0 height and then change the height when visible. You may need to have the others move up depending how you have it coded. Can you show us your code?

Yes, I will get the code in a few minutes. Your post is confusing me though… Setting visibility? What I’m asking is when you collapse a category above, I want the category under it to move up. And when I expand that first category, I would like for the one under it to move back down. (so it fills space)


Parent code:

local commands = vgui.Create( "DPanelList" )
		commands:SetPos( 0, 0 )
		commands:SetSize( tabs:GetWide(), tabs:GetTall() )
		commands:SetSpacing( 5 )
		commands:EnableHorizontal( false )
		commands:EnableVerticalScrollbar( true )

Basic Commands DCC code:

local basicplayer = vgui.Create( "DCollapsibleCategory", commands )
		basicplayer:SetPos ( 20, 5 )
		basicplayer:SetSize ( tabs:GetWide() - 55, 50 )
		basicplayer:SetExpanded( 1 )
		basicplayer:SetLabel( "" )
		basicplayer.Paint = function()
			draw.RoundedBox( 4, 0, 0, basicplayer:GetWide(), 20, Color( 230, 126, 34, 255 ) )
			draw.SimpleText( "Basic Commands", "CenterPrintText", basicplayer:GetWide() / 2, 10, Color(255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )

Money commands DCC code:

local moneygroup = vgui.Create( "DCollapsibleCategory", commands )
		moneygroup:SetPos ( 20, 60 )
		moneygroup:SetSize ( 900, 50 )
		moneygroup:SetExpanded( 1 )
		moneygroup:SetLabel( "Money Commands" )

Would love any insight!