Garry's Mod Wiki


  Panel Panel:Add( Panel object )
  Panel Panel:Add( string class )
  Panel Panel:Add( table table )


When provided with a string or table, this function will create a new vgui element with that name and set the parent to the panel that this method is called on. When provided with a panel it will use Panel:SetParent on the provided panel to set it to our source panel

Default Arguments

1 Panel object

Argument Overload: Class Name

1 string class
The class to be added.

Argument Overload: Panel Table

1 table table
The table to create the panel from.


1 Panel
New panel


Create a Panel with vgui.Register, and initialize a DScrollPanel with Panel:Add

local PANEL = {} function PANEL:Init() -- Guarantees only one instance of the frame is open at a time. if IsValid(SingleDFrame) then SingleDFrame:Remove() end local sw = ScrW() local sh = ScrH() self:SetSize(sw * 0.25, sh * 0.5) self:SetTitle("Window (Scroll)") self:Center() self:MakePopup() self.Canvas = self:Add("DScrollPanel") self.Canvas:Dock(FILL) end vgui.Register("DFrameScrollable", PANEL, "DFrame") SingleDFrame = vgui.Create("DFrameScrollable")