DIconLayout Panels Don't Fit Snug HELP PLEASE?

So I want to create a specific number of dpanels and make them fit the panel accurately

But using this:



	local test = vgui.Create( "DFrame" )
	
	test:SetSize( 250, 500 )
	test:Center()
	test:MakePopup()
	
	// Make the scroll panel
	local test2 = vgui.Create( "DScrollPanel", test )
	test2:SetPos( 0, 50 )
	test2:SetSize( test:GetWide(), test:GetTall() )
	
	// Make the IconLayout
	local test3 = vgui.Create( "DIconLayout", test2 )
	test3:SetSize( test:GetWide(), test:GetTall() )
	
	// Store Width
	local w = test3:GetWide()
	
	// Define Squares
	local amt = 12
	
	// Go through each and create based on math ratio
	for i = 1, amt do
		local pnl = test3:Add( "DPanel" )
		pnl:SetSize( w/amt, 50 )
	end	


It results in:

I suspected maybe the Scroll Panel had some strange offset so I removed it:



	//local test = vgui.Create( "Inventory" )
	local test = vgui.Create( "DFrame" )
	
	test:SetSize( 250, 500 )
	test:Center()
	test:MakePopup()
	
	// Make the scroll panel
	//local test2 = vgui.Create( "DScrollPanel", test )
	//test2:SetPos( 0, 50 )
	//test2:SetSize( test:GetWide(), test:GetTall() )
	
	// Make the IconLayout
	local test3 = vgui.Create( "DIconLayout", test )
	test3:SetSize( test:GetWide(), test:GetTall() )
	
	// Store Width
	local w = test3:GetWide()
	
	// Define Squares
	local amt = 12
	
	// Go through each and create based on math ratio
	for i = 1, amt do
		local pnl = test3:Add( "DPanel" )
		pnl:SetSize( w/amt, 50 )
	end	


but same results:

[lua]
test3:SetSpaceY( 5 ) //Sets the space in between the panels on the X Axis by 5
test3:SetSpaceX( 5 ) //Sets the space in between the panels on the Y Axis by 5
[/lua]

Thanks for the reply, but I am looking to make it fit in one line not space them out. As you can see the math should make it so they all stay on the one line fitting it completely but it doesn’t, it just has that stupid gap.

Ok then use DPanelList, I know it’s outdated, well you can say thanks to Garry who made this vgui outdated by the way it’s the only way to make a list of panels, the DIconLayout is working only when you need multiple panels per lines, when you want 1 panel per line, use DPanelList.

I would use http://wiki.garrysmod.com/page/Category:DGrid if you want them all on one line then.

Wow that was super useful, much appreciated sir you are truly a great help.