Category:DListView

From Garry's Mod
Jump to: navigation, search

Contents

DescriptionPanelPage

A data view with rows and columns.

Inherited Functions

Inherits the following functions from DPanel and its parents up to 3 levels deep:


Examples

Example

Creates a DListView and populates it with two columns and three items, only one of which can be selected at a time.

Selecting a row will print a console message containing the text of the row and its index.

local f = vgui.Create( "DFrame" )
f:SetSize( 500, 500 )
f:Center()
f:MakePopup()

local AppList = vgui.Create( "DListView", f )
AppList:Dock( FILL )
AppList:SetMultiSelect( false )
AppList:AddColumn( "Application" )
AppList:AddColumn( "Size" )

AppList:AddLine( "PesterChum", "2mb" )
AppList:AddLine( "Lumitorch", "512kb" )
AppList:AddLine( "Troj-on", "661kb" )

AppList.OnRowSelected = function( lst, index, pnl )
	print( "Selected " .. pnl:GetColumnText( 1 ) .. " ( " .. pnl:GetColumnText( 2 ) .. " ) at index " .. index )
end

Output:

Selected Troj-on ( 661kb ) at index 3
Selected Lumitorch ( 512kb ) at index 2
Personal tools
Navigation