I need to know when a tool strip menu item is about to be shown (in order to create the content on a JIT basis).
I have a potentially very large hierarchy of stuff. It can be navigated in a treeview, but also via "breadcrumbs", e.g. "Music > Pop > Michael Jackson > Bad". The breadcrumbs are implemented by a toolstrip, and each level is presented with a LinkLabel. When clicking a link, e.g. "Music", a context menu is dynamically built with all the siblings of the current item.
I am trying to create the illusion that the entire hierarchy is always loaded. When I fetch data, I make sure to get enough information to present a node AND to know whether that node has children. If it does have children, I create a dummy node with the special meaning "this item has unloaded children" and put it as the only child. This causes the treeview to render the node as expandable. I then use the BeforeExpand event of the treeview to fetch the next level and update the nodes collection just in time, when it's actually going to be displayed.
This works well for the tree, but I need to do the same thing for the breadcrumbs-style context menus. I already create a sub-menu for items that have children, putting my special "unloaded children" item in there. The problem is I can't find an event that lets me know when that sub-menu is about to be displayed. This can happen by hovering, clicking, keyboard navigation and perhaps more; I really don't want to hack it if there is a more appropriate hook I just haven't found..
In other words, what I need is something equivalent to "BeforeExpand" but for ToolStripMenuItem (the event btw ought to be called "NodeExpanding" according to MS' own naming guidelines, which say the gerund form ("ing") should be used rather than the "Before" prefix, and the past tense ("Expanded") rather than the "After" prefix).
I hope it's clear what I'm trying to do, and that someone knows how to solve this!