How do I assign a function to Contextmenustrip in c#?

Asked

Viewed 38 times

0

How do I assign a function to a Contextmenustrip that is on a Notifyicon?

I have the following code:

private void Thread_Notify_MouseClick(object sender, MouseEventArgs e)
{
    Thread_Notify.ContextMenuStrip = contextMenuStrip1;
}

void Exit(object sender, EventArgs e)
{
    Thread_Notify.Visible = false;
    Application.Exit();
}

The menu is already skilled and working perfectly:

inserir a descrição da imagem aqui

Need to assign the Exit() function to the exit option (exitToolStripMenuItem) from the menu.

1 answer

1


Just add the method as event Click of item.

sairToolStripMenuItem.Click += Exit;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.