• Painting and retrieve data from DListView?
    4 replies, posted
Hey everyone. I'm working with DListView, but I've encountered some problems. 1. I cannot seem to figure out how to target individual elements of the DListView to paint them. 2. Reading the wiki, I couldn't find any way to retrieve the data from a row that is selected. Any help with either of these conundrums is greatly appreciated :D - FP
[QUOTE=Fillipuster;50800610]1. I cannot seem to figure out how to target individual elements of the DListView to paint them. 2. Reading the wiki, I couldn't find any way to retrieve the data from a row that is selected.[/QUOTE] 1. To target the individual elements to paint it's a bit trickier, but I think you could do it by looping through list.Lines and list.Columns and overriding the paint functions of each of the panels in those tables 2. You just need to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DListView/OnRowSelected]DListView:OnRowSelected[/url] and then do row:GetValue( 1 )
[QUOTE=MPan1;50800612]2. You just need to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DListView/OnRowSelected]DListView:OnRowSelected[/url] and then do row:GetValue( 1 )[/QUOTE] Could I do it with double clicks instead of single click selections?
:snip: automerge [editline]30th July 2016[/editline] [QUOTE=Fillipuster;50800614]Could I do it with double clicks instead of single click selections?[/QUOTE] I think if you use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DListView/DoDoubleClick]DListView:DoDoubleClick[/url] and do line:GetValue(1) then it should work [editline]30th July 2016[/editline] Actually I'm not sure- but the code for the DListView's lines is [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dlistview_line.lua"]here[/URL]- GetValue seems to work on it from what I can tell
Here, from my scoreboard tutorial on how to target any specific element: [code] --[[ Line painting ]]-- for _, v in pairs ( player.GetAll() ) do local line = playerlist:AddLine( v:Name(), v:Frags(), v:Deaths(), v:Ping() ) function line:Paint( w, h ) --Paint the LINEs here end end --[[ Column header painting ]]-- for _, v in pairs( playerlist.Columns ) do function v.Header:Paint( w, h ) -- Paint the HEADERs here end v.Header:SetTextColor( Color( 255, 255, 255, 0 ) ) -- Set its text alpha with this incase you paint the text manually end [/code] [B]playerlist.[/B] -- Its the panel name of the DListView. Full reference: [url]http://wiki.garrysmod.com/page/Basic_scoreboard_creation[/url] Elements of the DListView can be found here: [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dlistview.lua[/url]
Sorry, you need to Log In to post a reply to this thread.