DPropertySheet help

So I am having problems with adding a DPropertySheet to a menu that uses + and - commands.

[lua] function Menu1()
CFrame = vgui.Create(‘DFrame’)
CFrame:SetSize(400, 300)
CFrame:SetPos(481, 262)
CFrame:SetVisible(false) --so it dont appear on start up
CFrame:SetTitle(‘Censored’)
CFrame:SetDeleteOnClose(false)
CFrame:MakePopup()

local PSheet1 = vgui.Create("DPropertySheet") 
PSheet1:SetParent("CFrame") 
PSheet1:SetVisible(false)
PSheet1:SetPos(479, 260) 
PSheet1:SetSize(298,298)

local SheetItemOne = vgui.Create( "DCheckBoxLabel" )
SheetItemOne:SetText( "Use Props?" )
SheetItemOne:SetConVar( "some_convar" )
SheetItemOne:SetValue( 1 )
SheetItemOne:SizeToContents()

PSheet1:AddSheet(“Settings”, SheetItemOne, “gui/silkicons/user”, false, false, “Settings” )
end

function openup()
CFrame:SetVisible(true)
end

function closedown()
CFrame:SetVisible(false)
end

concommand.Add("-c_menu",closedown)
concommand.Add("+c_menu",openup)
hook.Add(“Initialize”,“Menu1”,Menu1)[/lua]

How can I make it so that the PropertySheet only appears while I have my key bound to +c_menu held down? Also I am not sure what I did wrong but this is how it looks in game.

[img_thumb]http://img215.imageshack.us/img215/5032/dpsu.png[/img_thumb]

So how can I make is so that it is parented and will appear and disappear with the rest of the frame?

Also in this line right here
[lua]PSheet1:AddSheet(“Settings”, SheetItemOne, “gui/silkicons/user”, false, false, “Settings” )[/lua]
Where is says SheetItemOne, do you have to include EVERYTHING you want on the page in that spot right there?

Thanks for the help.

[lua]PSheet1:SetParent(“CFrame”)[/lua]

SetParent accepts a Panel not a string. The way to do it is:

[lua]PSheet1:SetParent(CFrame)[/lua]

Infact you don’t even need that line if you create it like this:

[lua]local PSheet1 = vgui.Create(“DPropertySheet”, CFrame)[/lua]

Also anything that is parented to ‘SheetItemOne’ will show/hide according to the current tab, you don’t have to add each one manually.

Awesome! Thank you! That should make it appear and disappear with the DFrame correct?

[EDITLINE] 10:23 [/EDITLINE]

Yeah I’m not sure, but I think the DPropertySheet is now behind my menu, because I get no errors at all but it doesn’t appear. I changed it to be parented the correct way, so I don’t think that’s the issue

Can you show us your updated code now?

[lua]function Menu1()
CFrame = vgui.Create(‘DFrame’)
CFrame:SetSize(400, 300)
CFrame:SetPos(481, 262)
CFrame:SetVisible(false) --so it dont appear on start up
CFrame:SetTitle(‘Censored’)
CFrame:SetDeleteOnClose(false)
CFrame:MakePopup()

local PSheet1 = vgui.Create("DPropertySheet") 
PSheet1:SetParent(CFrame) 
PSheet1:SetPos(479, 260) 
PSheet1:SetSize(298,298)

local SheetItemOne = vgui.Create( "DCheckBoxLabel" )
SheetItemOne:SetText( "Use Props?" )
SheetItemOne:SetConVar( "some_convar" )
SheetItemOne:SetValue( 1 )
SheetItemOne:SizeToContents()

PSheet1:AddSheet(“Settings”, SheetItemOne, “gui/silkicons/user”, false, false, “Settings” )
end

function openup()
CFrame:SetVisible(true)
end

function closedown()
CFrame:SetVisible(false)
end

concommand.Add("-c_menu",closedown)
concommand.Add("+c_menu",openup)
hook.Add(“Initialize”,“Menu1”,Menu1)[/lua]

All I did was update the parenting to the correct way, and then removed PSheet1:SetVisible(false)

[lua]
CFrame:SetPos(481, 262)
PSheet1:SetPos(479, 260)
[/lua]

There is your problem. When you set the position of a child Panel it is relative to the parent panel.

The correct way to do it is:

[lua]
PSheet1:SetPos(5, 30)
PSheet1:SetSize(CFrame:GetWide()-10, CFrame:GetTall()-35)
[/lua]

Ah, I didn’t even think about that! Thanks!

[EDITLINE]10:46[/EDITLINE]

Yup! Just tested in game. Works flawlessly - until I fuck something else up - thanks again.