Hi, i have a dynamic contextmenustrip that i put items to it in runtime using this code
strp[i] = new ContextMenuStrip();
strp[i].Items.Add("Delete from this List", null,showMessageBox);
i want to show a messagebox when the item clicked,
i can't use a method lik
void disp(object sender, EventArgs e)
{
messagebox.show("hi");
}
because the click handler must be in the exact line where the item is created because i'm making a loop of contextmenustrip with different names and same text, if i do that every contextmenustrip items will scope to the same click handler, so it must be in the exact line where the item is being created, how i can do that?
What I have tried:
i have tried this code
strp[i].Items.Add("Delete from this List", null, Click +=(b,g) => { MessageBox.Show("hi") });
but it gives error (cannot change void to system.handler) i tried to change it to
object sender, eventhandler t
but it doesn't work, i tried alot of other codes none of them worked