DListView
Description
A data view with rows and columns.
Parent
Derives methods, etc not listed on this page from DPanel.
Events
DListView:DoDoubleClick( number lineID, Panel line )
Called when a line in the DListView is double clicked.
DListView:OnRowSelected( number rowIndex, Panel row )
Called internally by DListView:OnClickLine when a line is selected. This is the function you should override to define the behavior when a line is selected.
Methods
DListView:Clear()
Removes all lines that have been added to the DListView.
DListView:ClearSelection()
Clears the current selection in the DListView.
DListView:DisableScrollbar()
Removes the scrollbar.
DListView:FixColumnsLayout()
This is used internally - although you're able to use it you probably shouldn't.
Internal helper function called from the PANEL:PerformLayout of DListView.
number DListView:GetDataHeight()
Returns the height of the data of the DListView.
See also DListView:SetDataHeight.
boolean DListView:GetDirty()
This is used internally - although you're able to use it you probably shouldn't.
See DListView:SetDirty.
number DListView:GetHeaderHeight()
Returns the height of the header of the DListView.
See also DListView:SetHeaderHeight.
number DListView:GetInnerTall()
Returns the height of DListView:GetCanvas.
Intended to represent the height of all data lines.
boolean DListView:GetMultiSelect()
Returns whether multiple lines can be selected or not.
See DListView:SetMultiSelect.
number, Panel DListView:GetSelectedLine()
Gets the currently selected DListView_Line index.
If DListView:SetMultiSelect is set to true, only the first line of all selected lines will be returned. Use DListView:GetSelected instead to get all of the selected lines.
boolean DListView:GetSortable()
Returns whether sorting of columns by clicking their headers is allowed or not.
See also DListView:SetSortable.
number DListView:GetSortedID( number lineId )
This is used internally - although you're able to use it you probably shouldn't.
Converts LineID to SortedID
DListView:OnClickLine( Panel line, boolean isSelected )
This is used internally - although you're able to use it you probably shouldn't.
Use DListView:OnRowSelected instead!
Called whenever a line is clicked.
DListView:OnRequestResize( Panel column, number size )
This is used internally - although you're able to use it you probably shouldn't.
Called from DListView_Column.
DListView:SelectFirstItem()
Selects the line at the first index of the DListView if one has been added.
DListView:SetDataHeight( number height )
Sets the height of all lines of the DListView except for the header line.
See also DListView:SetHeaderHeight.
DListView:SetDirty( boolean isDirty )
This is used internally - although you're able to use it you probably shouldn't.
Used internally to signify if the DListView needs a rebuild.
DListView:SetHeaderHeight( number height )
Sets the height of the header line of the DListView.
See also DListView:SetDataHeight.
DListView:SetMultiSelect( boolean allowMultiSelect )
Sets whether multiple lines can be selected by the user by using the ctrl or ⇧ shift keys. When set to false, only one line can be selected.
DListView:SetSortable( boolean isSortable )
Enables/disables the sorting of columns by clicking.
This will only affect columns that are created after this function is called. Existing columns will be unaffected.
DListView:SortByColumn( number columnIndex, boolean descending = false )
Sorts the items in the specified column.
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