Garry's Mod Wiki

DScrollPanel

Description

DScrollPanel is a VGUI Element similar to DPanel however it has a vertical scrollbar docked to the right which can be used to put more content in a smaller area. DScrollPanels are essentially DPanels with the Scroll Bar.

This can be used to replace the DPanelList with DPanelList:EnableVerticalScrollbar and get similar functionality as well as using a non-deprecated element.

If you would like to paint or edit the elements of the scrollbar use DScrollPanel:GetVBar. If you want to see if the scrollbar is visible then use the VBar.Enabled variable on the scrollbar's VBar.

Panel:DockPadding will not have an effect on children of this panel. Use the function on DScrollPanel:GetCanvas instead.

Parent

Derives from DPanel.

Methods

DScrollPanel:AddItem( Panel pnl )
Parents the passed panel to the DScrollPanel's canvas.
DScrollPanel:Clear()
Clears the DScrollPanel's canvas, removing all added items.
Panel DScrollPanel:GetCanvas()
Returns the canvas ( The panel all child panels are parented to ) of the DScrollPanel.
number DScrollPanel:GetPadding()
Gets the DScrollPanels padding
Panel DScrollPanel:GetVBar()
Returns the vertical scroll bar of the panel.
number DScrollPanel:InnerWidth()
Return the width of the DScrollPanel's canvas.
DScrollPanel:Rebuild()
DScrollPanel:ScrollToChild( Panel panel )
Scrolls to the given child
DScrollPanel:SetCanvas( Panel canvas )
This is used internally - although you're able to use it you probably shouldn't. Sets the canvas of the DScrollPanel.
DScrollPanel:SetPadding( number padding )
Sets the DScrollPanel's padding. This function appears to be unused.

Example

Creates a DScrollPanel and adds 100 DButtons to it.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 500, 500 ) frame:Center() frame:MakePopup() local DScrollPanel = vgui.Create( "DScrollPanel", frame ) DScrollPanel:Dock( FILL ) for i=0, 100 do local DButton = DScrollPanel:Add( "DButton" ) DButton:SetText( "Button #" .. i ) DButton:Dock( TOP ) DButton:DockMargin( 0, 0, 0, 5 ) end
Output:

Page Links


Special Pages


Wikis

?

Render Time: 114ms

DB GetPage 53
Generate Html 14
SaveChanges (1) 30
Render Body 0
Render Sidebar 14