Creating Dbuttons

How can I create Dbuttons based on a table.

So if i had

buttons = { 
     title = "Test1",


     title = "Test2",

it would create two buttons named test one and test 2 or generally create 2 buttons?

Ive tried using a for loop and failed

for k,v in pairs (buttons) do 
local button = vgui.Create("DButton", Parent)
--etc etc 

How did you fail? Post us some more detailed example and show us what exactly doesn’t work for you.

You need to set their pos’s unique, try an offset.

button:SetPos( k * 20, 20 )

that will set the first button at 20,20, second button at 40,20

You should adapt it to change the y when needed aswell.

I hope you understand what you need to do anyway.

Ok thanks for the help I fixed it, just another quick question, how can I place the first button at 0, 0 of a panel then use for example k * 60 for the rest?

(k-1) * 60

Think next time.

I prefer using DIConLayout and then adding to it through a loop. Does the positioning for me and is extremely neat)