As with all other control events, the first parameter is "sender".
If you cast this to a ContextMenuStrip control, then the SourceControl property is the control that was right clicked to give you the menu box:
private void contextMenuStrip1_Click(object sender, EventArgs e)
{
ContextMenuStrip cms = sender as ContextMenuStrip;
if (cms != null)
{
Console.WriteLine(cms.SourceControl.Name);
}
}
Do note that the SourceControl is the highest level you have associated the menu with: if you have associated the ContextMenuStrip with the form only, then it will always be the form as the SourceControl. You have to specify the ContextMenuStrip as the Control.ContextMenuStrip property of each control individually!