I'm trying to create a dynamic stripmenu, basically the program reads a XML file containing the structure for the menus, this I've done successfully.
But when i click on the menu "File" as example nothing happens, yes i know i have to create a function that will be called when i click the object, so i did that following the instructions of an website that explains how to do that in C#, however in VB.NET does not work, but in C# it does.
Here is the example that i saw in C#:
private void CreateMenuWithEventAndKey()
{
MenuStrip strip = new MenuStrip();
ToolStripMenuItem fileItem = new ToolStripMenuItem("&File");
// Create our first item with an image and wired to a click event
// Also sets Alt + 7 as the shortcut
ToolStripMenuItem itemWithEventAndKey = new ToolStripMenuItem(
"Delete Event", Image.FromFile("c:\\Delete.png"), deleteItem_Click,
(Keys)Shortcut.Alt7);
fileItem.DropDownItems.Add(itemWithEventAndKey);
strip.Items.Add(fileItem);
this.Controls.Add(strip);
}
// Event that is called from menu item.
private void deleteItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Delete Event");
}
Here is what i've done in VB.NET.
Private Sub BtnLogin_Click(sender As Object, e As EventArgs) Handles BtnLogin.Click
Dim menu As New MenuStrip()
Panel1.Visible = False
Dim fileitem = New ToolStripMenuItem("&file")
fileitem.DropDownItems.Add("New", Image.FromFile("C:\\add.png"), NewFile_click)
menu.Items.Add(fileitem)
Me.Controls.Add(menu)
End Sub
Private Sub NewFile_click(sender As Object, e As EventArgs)
MessageBox.Show("New")
End Sub
It does not build because it says that the object "sender" and "e" is not being passed in the call of the NewFile_Click, I don't know what to do.