DB Table Structure for Building Menu Dynamically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am having a harder time then I thought trying to come up with a table structure that allows for menus deeper then 2 levels. I am sure somebody out there has used a db to build menu's in VB dynamically
If anybody wants to chime in with a decent table design let me know or a URL to a decent design

BTW- I wasn't sure where to post this, hope nobody gets offended

Thanks

Chri
 
See recursion.


Chris Lane said:
Hi,

I am having a harder time then I thought trying to come up with a table
structure that allows for menus deeper then 2 levels. I am sure somebody out
there has used a db to build menu's in VB dynamically.
 
Thank You
A Recusrsive method is what I need to build the menu structure at runtime by level and position. Now I just have to figure out how to code that function. :)
 
Chris,

if you have a data structure, in our case just think of a simple table. you
can have something like

MenuItem_ID
MenuItem_Name
MenuItem_ParentID

Where ParentID referes to the parent MenuItemID.

So, before calling your recursive function you could do something like
(pardon my psuedo code)

For each MenuItem where MenuItemParentID = 0 (or null)
MenuBuilder (MenuItem)
Next

Function MenuBuilder(MenuItem)

if not (MenuItem is nothing) then
[Create MenuItem Object here]
MenuBuilder (GetMenuItemByParentID)
end if

End Function


Thats about it.

-CJ
Chris Lane said:
Thank You,
A Recusrsive method is what I need to build the menu structure at runtime
by level and position. Now I just have to figure out how to code that
function. :)
 
Back
Top