Your comment got me thinking & nosing around with Reflector again. I don't think it was intended for the timer to check if the item is disbled. It looks like the class was desinged to only enable the timer in the OnMouseEnter when it is not enabled, and to disable the timer (cancel) in the OnMouseLeave event. For some reason (which I cannot find), the timer does get enabled for disabled items when you move the mouse over it coming from an allready expanded item.
I did notice that the OnMouseEnter does check if this.Selected is true before enabling the timer. The Selected property in turn, will check this.CanSelect which always returns true (and is protected virtual). So by overring the CanSelect property, you can avoid the menu from expanding
class ToolStripItemEx : System.Windows.Forms.ToolStripMenuItem{
public override bool CanSelect {
get {
return this.Enabled;
}
}
}
Note that this however does NOT prevent the user from executing the click action of any of the childitems that have a shortcutkey by pressing that key (unless the childitems is disabled) as described in this porst: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=312139&SiteID=1
It might be possible to work around this issue by overring the click of the item and making sure the parent (and the parent's parent, ect) is not disabled.
Regards