Hello, if execute the attached code, the ContextMenuOpening event is not raised with ContextMenuStrip
how can I edit the contextmenu depending on the node? Can't use ContextMenu nor RadContextMenu for the purpose.
Maybe can I capture the mouse position before the contextmenu gets opened and find the tree node in some ways?
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
WindowsFormsApplication4
{
public
class
Form1 : Form
{
private
IContainer components;
private
ContextMenuStrip contextMenuStrip1;
private
ToolStripMenuItem aToolStripMenuItem;
private
Telerik.WinControls.UI.RadTreeView radTreeView1;
public
Form1()
{
this
.components =
new
System.ComponentModel.Container();
this
.radTreeView1 =
new
Telerik.WinControls.UI.RadTreeView();
this
.contextMenuStrip1 =
new
System.Windows.Forms.ContextMenuStrip(
this
.components);
this
.aToolStripMenuItem =
new
System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize) (
this
.radTreeView1)).BeginInit();
this
.contextMenuStrip1.SuspendLayout();
this
.SuspendLayout();
this
.radTreeView1.Location =
new
System.Drawing.Point(16, 12);
this
.radTreeView1.Size =
new
System.Drawing.Size(251, 152);
this
.radTreeView1.ContextMenuOpening +=
new
Telerik.WinControls.UI.TreeViewContextMenuOpeningEventHandler(
this
.radTreeView1_ContextMenuOpening);
this
.contextMenuStrip1.Items.AddRange(
new
System.Windows.Forms.ToolStripItem[] {
this
.aToolStripMenuItem});
this
.contextMenuStrip1.Name =
"contextMenuStrip1"
;
this
.aToolStripMenuItem.Name =
"aToolStripMenuItem"
;
this
.aToolStripMenuItem.Text =
"A"
;
this
.aToolStripMenuItem.Click +=
new
System.EventHandler(
this
.aToolStripMenuItem_Click);
//
// Form1
//
this
.ClientSize =
new
System.Drawing.Size(284, 261);
this
.Controls.Add(
this
.radTreeView1);
((System.ComponentModel.ISupportInitialize) (
this
.radTreeView1)).EndInit();
this
.contextMenuStrip1.ResumeLayout(
false
);
this
.ResumeLayout(
false
);
radTreeView1.ContextMenuStrip =
this
.contextMenuStrip1;
}
string
context =
"radTreeView1_ContextMenuOpening WAS NOT executed"
;
private
void
radTreeView1_ContextMenuOpening(
object
sender, Telerik.WinControls.UI.TreeViewContextMenuOpeningEventArgs e)
{
context =
"radTreeView1_ContextMenuOpening WAS executed"
;
}
private
void
aToolStripMenuItem_Click(
object
sender, EventArgs e)
{
MessageBox.Show(
this
, context);
}
}
}