Refreshing a derma

Hey,

I need my InventoryPanel (The black box on the right) to refesh or re-open after someone presses the use/drop/destroy button.

tried this but it’s not working :wink:
[LUA]
InventoryPanel:Remove()
timer.Simple( 0.5, function() InventoryPanel:Open() end)
[/LUA]

Well you didn’t give any code to work with, just something that’s obviously going to make an error.

Pretend that “InventoryPanel” needs to reopen after pressing the use or drop button as seen on the screenshot above.

You can’t display a menu that has been deleted. You would have to create the whole menu again.

The actual correct solution would be something along the lines of an index system. so when you remove an item by it’s ID you would remove it from an array or whatever structure you decide to use, and repaint the new list with the new inventory array.

How about refreshing a table. Is that possible?

[LUA]
for k,v in pairs(cl_inv) do
local TabInventoryItems = vgui.Create(“DPanel”)
TabInventoryItems:SetParent(MarketPlaceAmmunitionList)
TabInventoryItems:SetSize(780, 60)
TabInventoryItems:InvalidateLayout( true )
TabInventoryItemsList:AddItem( TabInventoryItems ) – Add the above item to our list

local info = items[k] – should be faster…

local InventoryItemsIcon = vgui.Create(“SpawnIcon”, TabInventoryItems)
InventoryItemsIcon:SetModel(info.model)
InventoryItemsIcon:SetSize(55,55)
InventoryItemsIcon:SetPos(0,0)
InventoryItemsIcon:SetMouseInputEnabled(false)

local InventoryItemsDetails = vgui.Create(“DLabel”, TabInventoryItems)
InventoryItemsDetails:SetText(v … " " … info.name)
InventoryItemsDetails:SetTextColor(Color(0,0,0,255))
InventoryItemsDetails:SizeToContents()
InventoryItemsDetails:SetPos(70, 5)

if info.useable then
local InventoryItemsButtonUse = vgui.Create(“DButton”, TabInventoryItems)
InventoryItemsButtonUse:SetSize(80, 25)
InventoryItemsButtonUse:SetPos(70, 25)
InventoryItemsButtonUse:SetText(“Use”)
InventoryItemsButtonUse:SetTextColor(color_white)
InventoryItemsButtonUse.Paint = function(self)
draw.RoundedBox(4,0,0,self:GetWide(),self:GetTall(),Color(0,0,0,200))
end
InventoryItemsButtonUse.DoClick = function()
RunConsoleCommand(“drp_useitem”, k)
– InventoryItemsDetails:SetText(v-1 … " " … info.name)
end
end
[/LUA]

@Edit: Appearently I accidently removed part of my post. Oh, well.
Can you do PrintTable( cl_inv ) and show us the output ?

Why don’t you organize your code a little better, split functions into initialization, layout and then data. You should be able to call your data function without having to reinitialize or re layout the entire panel.