Problem with Nested Collections

  • Thread starter Prakash C via .NET 247
  • Start date
P

Prakash C via .NET 247

Hi,

I am having a problem to create nested collections. I want tocreate a menu for my site. I created a MenuItem class which willstore the text that should appear on hyperlink. It may alsocontain other properties. Then a MenuItems class which inheritscollection base and implements ienumerator. The MenuItems classholds a collection of MenuItem objects.
Ok. Fine. Now, I will be having a nested menu, like Products ->Division -> Category -> Product. Likewise, I will be havingmenus of various levels for every top level menu, and within thesub menu i will have another sub menu, like that... I donno howto achieve it. Pls help me.
 
D

Davide Vernole [MVP]

Prakash C via .NET 247 said:
Hi,

I am having a problem to create nested collections. I want to
create a menu for my site. I created a MenuItem class which will
store the text that should appear on hyperlink. It may also contain
other properties. Then a MenuItems class which inherits collection
base and implements ienumerator. The MenuItems class holds a
collection of MenuItem objects.
Ok. Fine. Now, I will be having a nested menu, like Products ->
Division -> Category -> Product. Likewise, I will be having menus of
various levels for every top level menu, and within the sub menu i
will have another sub menu, like that... I donno how to achieve it.

Simply add a property to your MenuItem object. This property must be a
MenuItems type. So you could obtain a n-level hierarchy inside at your
object. This mean that you have to implement a persistent method to save
data that it consider this nested hierarchy.

e.g.

MenuItem
|__MenuItems
|__MenuItem1
| |__MenuItems
| |_MenuItem11
|__MenuItem2
| |__MenuItems
|__......

HTH
 
A

avnrao

your MenuItems class should look like this..

MenuItems
-- Current
-- MenuItems
-- Length

MenuItems should be implemented as a collection like this.. MenuItems[0]
gives a reference to MenuItems.

hth,
Av.
Hi,

I am having a problem to create nested collections. I want to create a
menu for my site. I created a MenuItem class which will store the text that
should appear on hyperlink. It may also contain other properties. Then a
MenuItems class which inherits collection base and implements ienumerator.
The MenuItems class holds a collection of MenuItem objects.
Ok. Fine. Now, I will be having a nested menu, like Products -> Division ->
Category -> Product. Likewise, I will be having menus of various levels for
every top level menu, and within the sub menu i will have another sub menu,
like that... I donno how to achieve it. Pls help me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top