Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Menu Object Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Menus
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01216226
Message ID:
01216319
Vues:
12
>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
________________________
Ben Santiago, MCP & A+
Programmer Analyst (SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS)
Eastern Suffolk BOCES - Student Data Services


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-Rich Cook
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform