HELP NEEDED - How do I grab a value/string from a DListView?
3 replies, posted
I am really new to Lua and can't understand how to get a value from the line I select using DListView.
For my script I want to select the Line on Derma then take a value from a column I want and send it with net.WriteString().
Here I am attempting to take the value from the Name column from the line I select and send it.
local plyList = vgui.Create("DListView")
plyList:SetParent(frame)
plyList:SetSize(frame:GetWide() - 10,380)
plyList:SetPos(5,30)
plyList:AddColumn("Name")
plyList:AddColumn("Steam ID")
plyList:AddColumn("DarkRP Job")
plyList:AddColumn("ULX Rank")
for k, v in pairs(player.GetAll()) do
plyList:AddLine(v:Nick(),v:SteamID(),v:getDarkRPVar("job"),v:GetNWString("usergroup"))
end
My Attempt:
net.Start("submitReport")
net.WriteString(LocalPlayer():Nick())
net.WriteString(plyList:GetSelectedLine():GetValue(1))
net.WriteString(textBox:GetValue())
net.SendToServer()
https://files.facepunch.com/forum/upload/305043/7c2258ab-8529-4c56-a9a3-f292a72cc2ed/699ebcde6e3bbecad2268b39d30f5daa.png
Sorry if it's unclear what I'm trying to ask. I have been searching the wiki and for over an hour.
Does GetValue even work with DListView?
Depending on the amount of columns, you can use panel:GetColumnText(Column) received from DListView.OnRowSelected(self, index, panel)
Please open the wiki page for DListView, it has the examples you are looking for.
You should visit the wiki ALWAYS before asking questions here.
Sorry, you need to Log In to post a reply to this thread.