Make a line (in DFrame) per value in a table

Hi everyone,
I tell you today because i’ve a problem :
I have a simple DFrame with a DListView.
In this DFrame, there is a DListView. When the player does a click on a line in this DListView, the value of this line is saved in a table, as that :


 local nicktable = {}
for k, v in pairs(player.GetAll()) do
 DermaCreateList:AddLine(v:Nick())
end
DermaCreateList.DoDoubleClick = function(lineID, line)
table.insert(nicktable, line:GetValue(1))
DermaCreateList:Hide()
....
end


And I would like to manage there is one of this value per line in an other DListView, so i tried that :


for k,v in pairs(nicktable) do
DermaSearchList:AddLine( v )
end


But in this other DFrame i don’t see my name i can see in the first DListView.

I don’t know how manage that… If you can help me please…
PS : With PrintTable( nicktable ) I can see my name after the table.insert, so the first part of the code is right i think…

Thanks in advance !
Regards,
GarrysDorian

What’s in nicktable?

Sorry, edit the code.
In the first DListView, there is name of player :


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

nicktable is a table with name of players.

What do you mean by “And I would like to manage there is one of this value per line in an other DListView”? You don’t want duplicates in DermaSearchList or the names aren’t appearing in DermaSearchList?

Very simple :
In the first DFrame, there is DListView with, for example : “Jerry”, “Dan”, “Chris”. If the owner of the DFrame realizes Double Click (DoDoubleClickFunction) on the name “Dan”, “Dan” is saved in a table.
And i would like that : The name “Dan” is on a line in the second DFrame (so in the second DListView).
I tried the code above but the name of “Dan” is saved (PrintTable says the name “Dan”) but there is no line with the name i click before…



 local nicktable = {}
for k, v in pairs(player.GetAll()) do
 DermaCreateList:AddLine(v:Nick())
end
DermaCreateList.DoDoubleClick = function(lineID, line)
    table.insert(nicktable, line:GetValue(1))
    DermaCreateList:Hide()
    DermaSearchList:AddLine(line:GetValue(1))
end


??

Probably wasn’t working because you looped through the nicktable before .DoDoubleClick was called and the name was added

Tried. If there is 2 DFrame in the game, that works… But this is not what i would like realize.
http://img11.hostingpics.net/pics/5908872016022800001.jpg
I double click on Chris Redfield and…
http://img11.hostingpics.net/pics/9825942016022800002.jpg
Nothing on the other DFrame…

I’ve one assumption :
The DermaSearch is initialized before the DermaCreate. When you doubleclick on a line, that add a lines in the other DFrame but the DFrame is not in the screen. So that produces nothing…

The code of DermaCreate and DermaSearch :



local nicktable = {}
local DermaSearchList = vgui.Create( "DListView", DermaSearch )
		DermaSearchList:SetPos(50, 50)
		DermaSearchList:SetSize(200, 200)
		DermaSearchList:SetMultiSelect(false)
		DermaSearchList:AddColumn("Name")
		for k, v in pairs(nicktable) do
			DermaSearchList:AddLine( v )
		end							
		function DermaSearchList:DoDoubleClick( lineID , line)
			DermaSearchSuit:SetVisible( true )
			DermaSearchSuit:MakePopup()
			DermaSearchSuit:SetMouseInputEnabled( true )
			DermaSearch:Hide()
		end
		DermaSearchList.Paint = function( self )
		draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color(120, 120, 120, 185) )
		surface.SetDrawColor( 25, 25, 180, 255 )
		surface.DrawOutlinedRect( 0, 0, self:GetWide(), self:GetTall() )	
		end

		local DermaCloseSearch = vgui.Create( "DButton", DermaSearch )
		DermaCloseSearch:SetText( "Close" )
		DermaCloseSearch:SetPos( 540, 5 )
		DermaCloseSearch:SetSize( 50, 15 )
		DermaCloseSearch.DoClick = function()
    	DermaSearch:Close()
    	OpenMenuComputer = false
		end
		DermaCloseSearch.Paint = function( self )
		surface.SetDrawColor(120, 20, 20, 255)
		surface.DrawOutlinedRect(0, 0, self:GetWide(), self:GetTall())
		end


local DermaCreateList = vgui.Create( "DListView", DermaCreate )
	DermaCreateList:SetPos(50, 50)
	DermaCreateList:SetSize(200, 200)
	DermaCreateList:SetMultiSelect(false)
	DermaCreateList:AddColumn("Name")

	for k,v in pairs(player.GetAll()) do
		DermaCreateList:AddLine(v:Nick())
	end
	function DermaCreateList:DoDoubleClick( lineID , line)
		table.insert(nicktable, line:GetValue(1) )
		DermaSearchList:AddLine( line:GetValue(1) )
		PrintTable( nicktable )
		DermaCreateSuit:SetVisible( true )
		DermaCreateSuit:MakePopup()
		DermaCreateSuit:SetMouseInputEnabled( true )
		DermaCreate:Hide()
	end
	DermaCreateList.Paint = function( self )
		draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color(120, 120, 120, 185) )
		surface.SetDrawColor( 25, 25, 180, 255 )
		surface.DrawOutlinedRect( 0, 0, self:GetWide(), self:GetTall() )	
	end



Thanks in advance for help !

Make sure it’s not something really simple causing the issue - like they aren’t overlapping each other, you’re going to need to set the y pos for each new item in the table, otherwise you’ll just see the last one as they’re being made on top of one and other

store a local number outside the loop, add one to it each time the loop goes around and use that for deciding the x pos

Personnally i think there is no problem as that (i don’t know i’m beginner but see the picture below).
If i show 2 DFrame simultaneously (1 DListView without DFrame but anyway), that works :
http://img11.hostingpics.net/pics/7216492016022800004.jpg

http://img11.hostingpics.net/pics/3069732016022800005.jpg

So I think i must search a way to save the line:GetValue() and Add a Line when i am in the second DFrame, because if there is no 2 DFrame simultaneously that doesn’t work…
So this is why i tried table.insert and the table works when the owner see the second DFrame, but doesn’t work too (code in the first message)…

UP… Same problem…

UP… :cry: