Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试这样做
panel.Enabled = false; // to disable all controls on panel at once panel.Cursor = Cursors.WaitCursor;
并且调试器显示 panel.Cursor 是 WaitCursor,但是当我将鼠标移到面板上时,光标仍然是箭头。
panel.Update(); panel.Refresh(); // does not help
那么,如何解决呢?
禁用的控件将不会接收 Windows 消息。最简单的方法是保持启用并以不同的方式处理“禁用”。
根据您的特定需要,另一种方法是将下面的代码添加到按钮的父级 - 您可以优化例程以仅在需要更改时调用。
this.MouseMove += (s, a) => { if (button2.Bounds.Contains(a.Location)) this.Cursor = Cursors.WaitCursor; else this.Cursor = Cursors.Default; };