开发者

Displaying tooltips on disabled menu items or alternative solutions in .NET

开发者 https://www.devze.com 2023-03-08 13:20 出处:网络
I\'m trying to display a tooltip on a disabled ToolStripMenuItem, to inform the user why it is disabled.

I'm trying to display a tooltip on a disabled ToolStripMenuItem, to inform the user why it is disabled.

My initial thought was (as events don't get fired on disabled controls) to pick up the MouseMove event on the parent MenuStrip instead and display the tooltip if over a disabled control. But the event doesn't seem to propagate up the parent MenuStrip as expected. This is how it works usually right? Example,开发者_C百科 a disabled textbox events would move up to the parent panel?

PS. I'm starting to think this bad idea UI design anyway? What's a better way to do it?


Tricky. I'd either accept that it's not possible to tell users (most users these days are happy that sometimes options are disabled because of context/selected data etc). Alternatively, you have to enable these items, and display popups or other warning messages when users try to invoke them.


I won't get in to whether it's bad UI design or not to display tooltips detailing the reason something is disabled.

However I did figure out how to do it for disabled buttons a number of years ago. I know it isn't your exact issue, but it is similar enough that the blog post I wrote may be of some use to you.


You should set ShowItemToolTips = true on the containing MenuStrip. The tooltip will show even when the ToolStripMenuItem is disabled (but it will not show if the entire MenuStrip is disabled).

This is an old question, so the functionality might have changed, but OP probably did the same mistake I did - my tooltip was not showing so I wrongly assumed it was because the ToolStripMenuItem was disabled.

Just wanted to point this out for future reference.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号