DListView Paint

Hi all,

Today I wanted to paint my DListView and had some weird outcomes. So I used the standard derma.Paint function and that seemed to only paint the background of the DlistView.
I then tried the SetTextColor function ( since I had a dark background ) and that didn’t work as well.
And then in the end the column buttons arn’t getting painted at all either.

How can I full paint the DListView?

Thanks,
Computer600

Look at the structure of the DListView on GitHub
I think you should be able to work it out from there.
You need to override the Paint functions of each and every element of a DListView including:
The line
The column

So how would I override exactly, I havn’t touched the derma side of garrysmod before that much?

Would I edit the code or…?

It think you’d have to iterate over the DListView.Lines then override it’s paint function,
like
[lua]k, v in pairs( DListView.Lines ) do
v.Paint = function()
– PAINT
end
end[/lua]
Alternatively, look into making your custom DListView element, which uses a custom PANEL:Paint function which also adds a custom line which also overrides its Paint.

Here’s what I used when I was trying to make an admin mod, canceled the project later and just kept the code on my laptop:

[lua]
local dlv = vgui.Create( “DListView”, menu )
dlv:SetPos( 250, 46 )
dlv:SetSize( 245, 300 )
dlv:SetMultiSelect( false )
dlv:AddColumn( “Player” )
dlv.m_bHideHeaders = true – hides the default header

local dlvIndex = vgui.Create( “DButton”, menu ) – custom header for the DListView
dlvIndex:SetPos( 250, 30 )
dlvIndex:SetSize( 245, 16 )
dlvIndex:SetText( “Players” )
dlvIndex.DoClick = function()
for k, Line in pairs( dlv.Lines ) do – deselect all lines on click
Line:SetSelected( false )
end
end

function dlvIndex:Paint()
draw.RoundedBoxEx( 6, 1, 0, self:GetWide() - 2, self:GetTall(), Color( 45, 45, 46 ), true, true )
end

for k, v in pairs( player.GetAll() ) do
dlv:AddLine( v:Nick() )
end

function dlv:Paint()
draw.RoundedBoxEx( 6, 0, 0, dlv:GetWide(), dlv:GetTall(), Color( 45, 50, 53 ) )
end

for k, v in pairs( dlv.Lines ) do
function v:Paint()
if k % 2 == 0 then
draw.RoundedBoxEx( 6, 0, 0, dlv:GetWide(), 25, Color( 57, 55, 54 ) )
else
draw.RoundedBoxEx( 6, 0, 0, dlv:GetWide(), 25, Color( 69, 69, 69 ) )
end
end
end
[/lua]