1

我有一些不可点击的上下文菜单项。他们只是报告某事的状态。我不喜欢光标仍然看起来像可点击的样子。

无论如何要改变这个?

没有像人们期望的那样的光标场。

4

2 回答 2

1

阿米拉姆把我送到了正确的方向。您不能在“ToolStripMenuItem”上设置光标,您必须在父 ContextMenuStrip 上设置它。

至于鼠标事件,必须在 ToolStripMenuItems 上进行。因为鼠标悬停在 ToolStripMenuItems 上时不会触发 MouseMove 事件。

    // Init Code
    contextMenuStrip1.Cursor = Cursors.Hand;
    recentMessagesToolStripMenuItem.MouseLeave += new EventHandler(SetCursorToHandOn_MouseLeave);
    recentMessagesToolStripMenuItem.MouseEnter += new EventHandler(SetCursorToArrowOn_MouseEnter);


    private void SetCursorToArrowOn_MouseEnter(object sender, EventArgs e)
    {
        contextMenuStrip1.Cursor = Cursors.Arrow;
    }

    private void SetCursorToHandOn_MouseLeave(object sender, EventArgs e)
    {
        contextMenuStrip1.Cursor = Cursors.Hand;
    }
于 2012-07-09T15:57:14.657 回答
1

处理整个 ToolStrip 的 MouseMove 事件,检查当前鼠标位置是否在 toolStripItem.Bounds 之间。如果是这样,请更改 ToolStrip.Cursor

于 2012-07-09T07:13:27.823 回答