The following code example creates an event handler for the C1CommandMenu.Popup event of the C1ContextMenu. The code in the event handler determines which of two controls a PictureBox named pictureBox1 and a TextBox named textBox1 is the control displaying the shortcut menu.
Depending on which control caused the C1ContextMenu to display its shortcut menu, the control shows or hides the appropriate menu items of C1Command.
This example requires that you have an instance of the C1ContextMenu class, named c1ContextMenu1, defined within the form. c1ContextMenu should have "Copy", "Find", "Change Picture" menu items. This example also requires that you have a TextBox and PictureBox added to a form and that the C1ContextMenu property of these controls is set to c1ContextMenu1.
private void c1ContextMenu1_Popup(object sender, EventArgs e) { Control c = c1ContextMenu1.SourceControl; // Copy and Find is dispayed for textBox1 c1CommandCopy.Visible = (c == textBox1); c1CommandFind.Visible = (c == textBox1); // Change Picture is dispayed for pictureBox1 c1CommandChangePicture.Visible = (c == pictureBox1); }