Home All Groups Group Topic Archive Search About

Can someone help me with this menu?

Author
30 Apr 2007 8:43 AM
Carol
I'm fairly new at this and trying to create a dynamic menu.

I use the function getMANames to put all the submenu item names into
an array. I am confident this sub is working properly.

When I look in debug mode the object insertJobMenu is reporting the
correct number of items. If I look at one of those items it has the
correct name. However when I run the code I don't get a drop-down
menu. I can see "InsertJobs" on the menu bar, however when I hover
over it nothing happens. Can anyone tell me what I'm doing wrong?

        Dim insertJobMenu As New MenuItem("InsertJobs")

        Dim MANames As String() = getMANames()
        For i = 0 To UBound(MANames)
            Dim insertMenuItem As New MenuItem(MANames(i))
            insertJobMenu.MenuItems.Add(insertMenuItem)
        Next

        Dim myMenu As New MainMenu(New MenuItem() {insertJobMenu})
        Menu = myMenu

Thanks,
Carol

Author
30 Apr 2007 1:38 PM
rowe_newsgroups
On Apr 30, 4:43 am, Carol <cwapsh***@london.edu> wrote:
Show quoteHide quote
> I'm fairly new at this and trying to create a dynamic menu.
>
> I use the function getMANames to put all the submenu item names into
> an array. I am confident this sub is working properly.
>
> When I look in debug mode the object insertJobMenu is reporting the
> correct number of items. If I look at one of those items it has the
> correct name. However when I run the code I don't get a drop-down
> menu. I can see "InsertJobs" on the menu bar, however when I hover
> over it nothing happens. Can anyone tell me what I'm doing wrong?
>
>         Dim insertJobMenu As New MenuItem("InsertJobs")
>
>         Dim MANames As String() = getMANames()
>         For i = 0 To UBound(MANames)
>             Dim insertMenuItem As New MenuItem(MANames(i))
>             insertJobMenu.MenuItems.Add(insertMenuItem)
>         Next
>
>         Dim myMenu As New MainMenu(New MenuItem() {insertJobMenu})
>         Menu = myMenu
>
> Thanks,
> Carol

Are you sure getMANames() is returning a populated string array? I
modified you code to use a hard coded array since for testing and
everything works fine. Also I suggest you turn on Option Explicit and
Option Strict - looking at your loop it seems they are turned off.

BTW, here's the test code I used:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

        Dim insertJobMenu As New MenuItem("InsertJobs")

        Dim MANames As String() = {"Item1", "Item2", "Item3"}

        For i As Integer = 0 To UBound(MANames)
            Dim insertMenuItem As New MenuItem(MANames(i))
            insertJobMenu.MenuItems.Add(insertMenuItem)
        Next

        Dim myMenu As New MainMenu(New MenuItem() {insertJobMenu})
        Menu = myMenu

    End Sub

Thanks,

Seth Rowe
Author
30 Apr 2007 3:31 PM
Carol
Seth,

thanks so much for putting in the time to try this out - but there
must be something else going on here because I copied in your code and
it's still not working!

I did actually have this working last week, then it stopped, I
couldn't figure out what I'd changed, and it hasn't worked since. Most
frustrating!

I don't really know where I'm supposed to use those options... though
presumably I wouldn't need them just to get your simplified example
working. Could I somehow have turned off drop-down menus for the whole
project?

.....  OK I've got it working now, by deleting the menus I'd manually
configured, and the MainMenu1 object from the form designer. Still
don't have a clue why it was doing this but at least I can make some
progress now!

Thanks again,
Carol


On Apr 30, 2:38 pm, rowe_newsgroups <rowe_em***@yahoo.com> wrote:
Show quoteHide quote
> On Apr 30, 4:43 am, Carol <cwapsh***@london.edu> wrote:
>
>
>
>
>
> > I'm fairly new at this and trying to create a dynamic menu.
>
> > I use the function getMANames to put all the submenu item names into
> > an array. I am confident this sub is working properly.
>
> > When I look in debug mode the object insertJobMenu is reporting the
> > correct number of items. If I look at one of those items it has the
> > correct name. However when I run the code I don't get a drop-down
> > menu. I can see "InsertJobs" on the menu bar, however when I hover
> > over it nothing happens. Can anyone tell me what I'm doing wrong?
>
> >         Dim insertJobMenu As New MenuItem("InsertJobs")
>
> >         Dim MANames As String() = getMANames()
> >         For i = 0 To UBound(MANames)
> >             Dim insertMenuItem As New MenuItem(MANames(i))
> >             insertJobMenu.MenuItems.Add(insertMenuItem)
> >         Next
>
> >         Dim myMenu As New MainMenu(New MenuItem() {insertJobMenu})
> >         Menu = myMenu
>
> > Thanks,
> > Carol
>
> Are you sure getMANames() is returning a populated string array? I
> modified you code to use a hard coded array since for testing and
> everything works fine. Also I suggest you turn on Option Explicit and
> Option Strict - looking at your loop it seems they are turned off.
>
> BTW, here's the test code I used:
>
>     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
>         Dim insertJobMenu As New MenuItem("InsertJobs")
>
>         Dim MANames As String() = {"Item1", "Item2", "Item3"}
>
>         For i As Integer = 0 To UBound(MANames)
>             Dim insertMenuItem As New MenuItem(MANames(i))
>             insertJobMenu.MenuItems.Add(insertMenuItem)
>         Next
>
>         Dim myMenu As New MainMenu(New MenuItem() {insertJobMenu})
>         Menu = myMenu
>
>     End Sub
>
> Thanks,
>
> Seth Rowe- Hide quoted text -
>
> - Show quoted text -