我通过以下方式自定义了右键菜单:
lineGraphControl1.ContextMenuBuilder += new ZedGraphControl.ContextMenuBuilderEventHandler(MyContextMenuBuilder);
并且
private void MyContextMenuBuilder(ZedGraphControl control, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
{
// create a new menu item
ToolStripMenuItem item = new ToolStripMenuItem();
// This is the user-defined Tag so you can find this menu item later if necessary
item.Name = "simple_cursor";
// This is the text that will show up in the menu
item.Text = "Simple Cursor";
item.CheckOnClick = true;
// Add a handler that will respond when that menu item is selected
item.Click += new System.EventHandler(DisplaySimpleCursor);
// Add the menu item to the menu
menuStrip.Items.Add(item);
}
但是菜单简单光标在被点击时不会被选中。我尝试在函数DisplaySimpleCursor()
中强制发送器,但它不起作用。
当我调试我的应用程序时,我看到在DisplaySimpleCursor()
中,发送器的属性Checked被设置为true。
我错过了什么?