I'm trying to show a message box alert when the user clicks on a MenuItem inside a context menu. Here is the context menu code:
public Form1()
{
MenuItem mni = new MenuItem();
mni.Text = "BackLog Task";
mni.MenuItems.Add("Backlog Task (1)");
mni.Click += new EventHandler(this.mni_Click);
contextMenu1.MenuItems.Add(mni);
notifyIcon1.Visible = true;
notifyIcon1.Icon = new System.Drawing.Icon
(System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal)
+ @"\icon.ico");
notifyIcon1.Text = "Right-click me!";
notifyIcon1.ContextMenu = contextMenu1;
InitializeComponent();
}
Here is the click event handler :
void mni_Click(object sender, EventArgs e)
{
MessageBox.Show("Back Log Event Handler");
}
But the click event is never fired. Does any have any idea what might be wrong ??