Derma DListView help.

Hello FP

I’m trying to make a list, and when i click a player on the list, it’ll show their stats. The issue I’m getting is if I click on another player, or myself again, it’ll just keep re-drawing the text over each other. Is there any solution to prevent this?

[LUA]
function scBounties.wantedList()
local Frame = vgui.Create( “DFrame” )
Frame:SetPos( ScrW()/3, 50 )
Frame:SetSize( 400, 350 )
Frame:SetTitle( “Altis Bounties” )
Frame:SetVisible( true )
Frame:SetDraggable( false )
Frame:ShowCloseButton( true )
Frame:MakePopup()

	//the bar background
	Frame.list = vgui.Create("DListView",Frame)
	Frame.list:Dock(FILL)
	Frame.list:SetWide(50)
	Frame.list:AddColumn("Name")
	Frame.list:SetMultiSelect(false)
	Frame.list:DockMargin(10,10,Frame:GetWide()/2,10)
	
	for k, v in pairs ( player.GetAll() ) do
					
		local newline = Frame.list:AddLine(v:Nick(),team.GetName( v:Team() ))
		newline.v = v
				

		Frame.list.OnRowSelected = function(  rowindex, row )
			
			local lineElement = Frame.list:GetLine(Frame.list:GetSelectedLine())
			local selectedPlayer = lineElement.v
			
			print("Player Selected : " .. tostring(selectedPlayer) .. tostring(row))
			
			scBounties.showCrimes(Frame, selectedPlayer, row)
			
		end
	end

end

function scBounties.showCrimes(Frame, pl, row)
local oldD = nil
local newD = row

if newD == oldD then 	oldD = row  return end


Frame.Info = vgui.Create("DLabel", Frame)
Frame.Info:SetPos(0,50)
Frame.Info:AlignLeft(200)
Frame.Info:SetText("Avalible Bounties: " .. tostring(pl))
Frame.Info:SetTextColor(color_black)

end
[/LUA]

Help will be appreciated a lot, thanks.

Skimming through the code I don’t see any Remove() functions so Id kinda fidget with that.

But I feel like this might get some dumb rates. XD


if !Frame.Info:IsHovered() then
		
	Frame.Info:Remove()

end

Add something like that, you can use what you want, but that is just an example. You need a :Remove() function to get rid of the existing DLabel.

Hm, doesn’t seem to work with DListView.

A better idea would be to just create the DLabel once, setting its text as blank/hiding it so it isn’t visible till you use it
[lua]Frame.Info:SetText( ‘’ )
– or
Frame.Info:Hide()[/lua]

Then in Frame.list.OnRowSelected
[lua]Frame.Info:SetText( ‘…’ )
Frame.Info:Show() – if hidden[/lua]

I see, I’ll give it a try, I’ve been experimenting with a few things. Just seeing wich fits best.