Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16044

VS 2015 Getting null error with manually placed MenuStrip

$
0
0
Code:

Private Sub AddNewDrawerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AddNewDrawerToolStripMenuItem.Click
    Dim Title As String = InputBox("Enter a title for your new drawer.")
    Dim NewDrawer As ToolStripMenuItem = New ToolStripMenuItem(My.Resources.DrawersPNG) With {.Text = Title}
    Dim AddBtn As ToolStripMenuItem = New ToolStripMenuItem(My.Resources.Add) With {.Text = "Add Shortcut"}
    AddHandler AddBtn.Click, AddressOf AddBtn_Click
    NewDrawer.DropDownItems.Add(AddBtn)
    MenuStrip1.Items.Add(NewDrawer)
End Sub

MenuStrip1 has been added via the designer, but when debugging, it shows up as "nothing".
Any ideas?

What I have tried:

I tried adding a new variable
Code:

Private WithEvents MyMenu as new MenuStrip
, then in the formload event;
Code:

MyMenu = Menu1
.
Then, of course, replacing MenuStrip1 in the above code to MyMenu.
Same result.

Name:  ScrnSht1.jpg
Views: 31
Size:  27.7 KB
Name:  ScrnSht2.jpg
Views: 31
Size:  33.0 KB
Attached Images
  

Viewing all articles
Browse latest Browse all 16044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>