Placing sub-menus within a DMultiChoice panel?

Can anyone help me to create a DMultiChoice box that contains sub-menus? I want to put a list of items into different groups and have the user able to choose only one item, within a group.

I’ve got something that creates the sub-menus, I just want to be able to put that menu tree into a DMultiChoice panel.


for k, v in pairs(GAMEMODE.DataBase.Items) do
	if string.find(k,"item_(%a*)") then
		self.Menu1:AddChoice(k)
	elseif string.find(k,"armor_(%a*)") then
		self.Menu2:AddChoice(k)
	elseif string.find(k,"weapon_(%a*)") then
		self.Menu3:AddChoice(k)
	else
		self.Menu4:AddChoice(k)
	end
end

-edit- Nevermind! Found something that works better!

DMultiChoice doesn’t have submenus, only DMenu does. But to not leave you empy handed I made an immitation.

Type TestMenu in the console to spawn it.
[LUA]
local function MakeMenu()
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetSize( 110,133 )
DermaPanel:Center()
DermaPanel:SetTitle( “Panel Test” )

local List= vgui.Create( "DMultiChoice", DermaPanel)
List:SetPos(5,28)
List:SetSize( 100, 20 )
List.OpenMenu = function() 

	local function FindParent(Panel)
		if(IsValid(Panel:GetParent()) && IsValid(Panel:GetParent():GetParent()))then
			return FindParent(Panel:GetParent())
		else
			return Panel
		end
	end
	
	local MenuButtonOptions = DermaMenu() -- Creates the menu
	local SubMenu = MenuButtonOptions:AddSubMenu("hello") -- Add options to the menu
	SubMenu:AddOption("my", function() Msg("My") end)
	SubMenu:AddOption("friend", function() Msg("Friend") end)
	MenuButtonOptions:AddOption("how", function() Msg("How") end )
	MenuButtonOptions:AddOption("are", function() Msg("Are") end )
	MenuButtonOptions:AddOption("you", function() Msg("You") end )
	MenuButtonOptions:AddOption("?", function() Msg("?") end )
	MenuButtonOptions:Open() -- Open the menu AFTER adding your options
	
	local Parent = FindParent(List) --Search for the parent to get screen position
	local X,Y = Parent:GetPos()
	local X2, Y2 = List:GetPos()
	X = X+X2
	Y = Y+List:GetTall()+Y2
	MenuButtonOptions:SetPos(X, Y) --Set the position under the menu
end

end
concommand.Add(“TestMenu”, MakeMenu)
[/LUA]

Opps didn’t see your edit, oh well it’s there for a reference.

I think I’ll save it somewhere anyway, could come in handy one day… Thanks a lot!