Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Menu Object Question
Message
From
22/04/2007 10:08:53
 
General information
Forum:
ASP.NET
Category:
Menus
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01216226
Message ID:
01218675
Views:
13
Ben,

At runtime, I'm not seeing names for *any* of the MenuItems, not just the "-" ones. Have you managed yet to find a way around this?

~~Bonnie



>>You say you are traversing the menu object at runtime, but when at runtime?
>    Not quite sure I understand this question. What do you mean by "when at runtime?"
>
>>Are you sure everything has been intialized?
>    I am pretty sure. If it wasn't, I'd probably be getting NullReferenceExceptions.
>
>>Have you thought about using the Tag property of the menu item?
>    I thought about it, but then it's an extra step that all the programmers involved in the project have to remember to populate the TAG field when they create or modify a Menu Item.
>
>>(I am answering your questions with even more questions :)
>    Not a problem, brainstorming is good, great way to see things you missed.
>
>>Could you please post your code that you use to traverse the menu object?
>
>    Private Sub ProcessMenuItems(ByVal objMenuItems As Menu.MenuItemCollection, ByVal strMenuPath As String)
>        '************************************************************************
>        ' Procedure/Function: ProcessMenuItems()
>        ' Author: Ben Santiago
>        ' Last Revision: 05/25/2006
>        ' Description:
>        '       This routine process each menu item in the supplied collection,
>        '       storing it's MenuText into an internal array and recursivly calling
>        '       itself in order to process any child menu items that may be present.
>        '
>        ' Structure:
>        '       MenuName|MenuText|MenuText|Etc...
>        '
>        '       MenuName
>        '              MenuText
>        '                     MenuText
>        '                            Etc...
>        '************************************************************************
>
>        '***************************************
>        ' Initialize Variables
>        '***************************************
>        Dim objCurrentItem As MenuItem
>        Dim intCurrentItem As Short
>        Dim strCurrentMenuPath As String
>
>        '***************************************
>        ' Process Each Menu Item
>        '***************************************
>        For intCurrentItem = 0 To (objMenuItems.Count - 1)
>            '***************************************
>            ' Initialize Values Used For Loop
>            '***************************************
>            objCurrentItem = objMenuItems(intCurrentItem)
>            If strMenuPath <> "" Then
>                If objCurrentItem.Text = "-" Then
>                    strCurrentMenuPath = strMenuPath & "|----------"
>                Else
>                    strCurrentMenuPath = strMenuPath & "|" & objCurrentItem.Text
>                End If
>            Else
>                strCurrentMenuPath = objCurrentItem.Text
>            End If
>
>            '***************************************
>            ' Remove Single Ampersands (&) From String
>            '***************************************
>            strCurrentMenuPath = strCurrentMenuPath.Replace("&&", Chr(240))
>            strCurrentMenuPath = strCurrentMenuPath.Replace("&", "")
>            strCurrentMenuPath = strCurrentMenuPath.Replace(Chr(240), "&")
>
>            '***************************************
>            ' Add Menu Item Name
>            '***************************************
>            strCurrentMenuPath = objCurrentItem.Name & "|" & strCurrentMenuPath
>
>            '***************************************
>            ' Store The Current Menu Item "Path & Text" Into The Array
>            '***************************************
>            Me._arrMenuStructure.Add(strCurrentMenuPath)
>
>            '***************************************
>            ' If Current Menu Item Has Children, Call This Method Recursively
>            '***************************************
>            If objCurrentItem.MenuItems.Count > 0 Then
>                Me.ProcessMenuItems(objCurrentItem.MenuItems, strCurrentMenuPath)
>            End If
>        Next
>    End Sub
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform