Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

c# - Windows Forms | MenuStrip Sub-Items (ToolStripMenuItem) changing Cursor won't work

I want to have a Hand Cursor for all ToolStripMenuItems.

So i change it in the MouseEnter and MouseLeave Events with this.Cursor = Cursors.Hand; & this.Cursor = Cursors.Default;. I've disabled latter for debugging purpose, so i can see if it changes at all.

It only works for "Root" Items. Not for their Sub-ToolStripMenuItems. The Events fire, it's just like the Cursor get's overridden by Sub-Items.

Any help would be appreciated, it looks weird with the default Cursor. I am using the latest version of VS 2019 and work with .NET Framework 4.8

Here is a little screen:

Problem Description as Screen

System-Info:

  • Edition: Windows 10 Pro
  • Version: 20H2
  • OS-Build: 19042.746
question from:https://stackoverflow.com/questions/65867656/windows-forms-menustrip-sub-items-toolstripmenuitem-changing-cursor-wont-wo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This works fine for me, both for root and sub items:

    private void ...ToolStripMenuItem_MouseMove(object sender, EventArgs e)
    {
        this.Cursor = Cursors.Hand;
    }

    private void ..ToolStripMenuItem_MouseLeave(object sender, EventArgs e)
    {
        this.Cursor = Cursors.Default;
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...