|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can someone help me with this 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 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. Are you sure getMANames() is returning a populated string array? I> > 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 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 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 -
there is no 64-bit Jet (MS Access) OLEDB driver.
Problem with: Use the following method to smooth edges of screen fonts: if ClearType is selected COM problem Persistent settings Publishing problem a vb calculator, but with a twist.?? vb.net c# mix Send keystroke to a datagridview control Can someone tell me where to post a code question for the following Forms |
|||||||||||||||||||||||