![]() ![]() I'm happy to have discourse concerning the architecture here - no worry about offense. Is there actually some benefit to displaying a context menu strip menu relative to a menu menu strip menu? I don't think so. Also if later I decide to use a different part of the menu as a context menu, I don't have to transplant all the main menu portion into a new context menu strip, or part of the context menu strip into another new context menu stip. Most of the reason I suggested the solution above was because I wanted to simplify my menu, by encapsulating the lacking functionallity, and not have to enter custom code in the designer back end each time. Then I have to deal with all my menus distributed in seperate objects in the designer. If that was the suggested way (not suggesting mine is) to accomplish the same task why would I have to manually insert designer lines of code, for every possible context menu, which the designer doesn't allow me to do in the first place? (via the GUI) 'It can be modified using the Windows Form Designer. 'NOTE: The following procedure is required by the Windows Form Designer Your editing the area of the designer generated code (which I've done before, this makes the task more complicated, which was the opposite to what I wanted to do) but according to VS. That appears to be more intensive than a proper solution. If Not bIsContext Then 'normal render of menu.ĮlseIf pContext = Nothing Then 'context menu at the current mouse co-ord'sĮlse 'context menu at the point specified in the function call. Protected Overrides ReadOnly Property DropDownLocation() As ĭim pBase As Point = MyBase.DropDownLocation ''' Overriden to change the location of drawing the menu based on the developers request. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) ''' Overriden to allow reset of the Context option that informas the control to display as context. ''' Shows the specified ContextMenuItem at the default position in the menu. Shadows Sub ShowDropDown(ByVal pSpecificScreenPoint As Point) ''' The Point to display the menu at, if Nothing the MousePosition is used. ''' Shows the specified ContextMenuItem at the screen point specified Shadows Sub ShowDropDown(ByVal bContext As Boolean) ''' bContext=True - displays the context menu at the current screen co-ordinates Private bIsContext As Boolean = False 'tracks if the next display show be with different coordinates. Private pContext As Point 'specific point for the context menu instead of the default screen position. Bork, free to use because MS pissed me off too much with lost features in VB6. Lastly DON'T use the ContextMenu Property in the forms designer on that control because they will conflict. Call the Context menu from inside the MouseUp routine (like VB6), place code like the following. Populate the Main Menu as normal, EXCEPT use the Class below, "ContextMenuItem", instead of the normal ToolStripMenuItem to create the parents you want to reuse as context menus. Add the Class Listed below to your project. (previously I resorted to 3rd party menus because I usually reuse my main menu portions as context menus) Here is one answer that I found that appears to be the simplest, and allows me to use the built in menus again. ![]() HOW DO YOU RE-USE A MENUSTRIP OBJECT AS A CONTEXT MENU? Though I would just share this because it has been a big annoyance since VS.NET 2002 for me, now with 2005 I found the menu's are still missing one simple feature.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |