Can someone help me with this menu?

C

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
 
R

rowe_newsgroups

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
 
C

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
 

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

Top