0

I have some code:

_Item.MouseDown += new MouseEventHandler(delegate(Object o, MouseEventArgs a)
{
    SrcRoot = BuilderParametresPath[_index].pngPath;
    DstRoot = BuilderParametresPath[_index].scenesPath;
    TextsXmlFileName = BuilderParametresPath[_index].textsPath;
    NavigationSystemPath = BuilderParametresPath[_index].hintPath;
    LevelsXmlFileName = BuilderParametresPath[_index].LevelsFilePath;

    if (a.Button == MouseButtons.Right)
    {
        ContextMenuStrip docMenu = new ContextMenuStrip();
        ToolStripMenuItem deleteLabel = new ToolStripMenuItem();
        deleteLabel.Text = "Удалить";
        docMenu.Items.AddRange(new ToolStripMenuItem[] { deleteLabel });
        ocMenu.Show(MousePosition);
    }
});

But it does not work, because pressing the right button does not work out. What can be done?

user2995099
  • 35
  • 2
  • 8

1 Answers1

0

Add a contextMenuStrip control to the form.

Now enter some menu items in the menu strip.

Click the target control which may be button/textbox/form and go to properties and in the properties select ContextMenuStrip and set the required contextMenuStrip control.

Then the context menu strip for the target control will appear when you right click to the targetead control.

Rezoan
  • 1,745
  • 22
  • 51