Results 1 to 3 of 3

Thread: Vertical Menustrip [2005]

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    2

    Vertical Menustrip [2005]

    Hi all,

    I want to use a vertical menustrip which should be "arrow-friendly".
    No mouse will be available, just a remote control with the arrow keys.

    I want to achieve the following scenario:
    User uses up/down arrows to browse through vertical menu-items.
    User sees drop-down menus if they exists for a specific menu-item.
    User uses ENTER to toggle to dropdown items or up/down arrows to continue to browse through the main menu items.
    (this scenario is much like moving the mouse vertically over the items)

    The default vertical menu behavior is as follows:
    User uses up/down arrows to browse through vertical menu-items.
    User comes across a menu item that has dropdown items.
    User uses up/down arrows to select another item but finds himself trapped in
    the dropdown list, the focus went directly to a dropdown item...
    User is forced to press right or left arrow to re-focus the main vertical menu.

    I tried to code the desired behavior through events and select methods with no success.

    Any ideas or code samples would be greatly appreciated.

    Thank you,
    thanasis

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: Vertical Menustrip [2005]

    It's not hard to do, you just need to make sure your tab-orders are correct. Then, on the key-press event of each "menu item", you check for up-arrow or down arrow and call "move next focus" or "move previous focus". On enter or right arrow, you open your sub-menu and repeat...

    You said you tried to code it via events. Post what you have and what specific problems you were having and we can be of further help.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    2

    Re: Vertical Menustrip [2005]

    Hi Jenner, thanks for your reply.

    I am sorry I did not explain my issue well.
    I have a single menustrip with multiple toolstripmenuitems.
    Some toolstripmenuitems have dropdown toolstripmenuitems.
    There is no key-press event for a toolstripmenuitem (is there?) .

    I use ProcessCmdKey to override up & down arrows as follows:

    Code:
    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
            Dim keyPressed As Keys = CType(msg.WParam.ToInt32(), Keys)
    
            ' Process keyPressed.
    
            Select Case keyPressed
    
                Case Keys.Up
                    Dim it As ToolStripMenuItem = MenuStrip1.GetNextItem(findcuritem(), ArrowDirection.Left)
                    it.ShowDropDown()
    
                    it.Select()
    
                    Return True
    
                Case Keys.Down
                    Dim it As ToolStripMenuItem = MenuStrip1.GetNextItem(findcuritem(), ArrowDirection.Right)
                    it.ShowDropDown()
    
                    it.Select()
                    Return True
          
                Case Else
    
                    ' Return the key message so it can be
    
                    ' processed by this control.
    
                    Return MyBase.ProcessCmdKey(msg, keyData)
    
            End Select
        End Function
    -->findcuritem is a function that returns the currently selected menu item.

    This way, when I come accross a menuitem that has dropdown items, the dropdown list is shown but not selected, as opposed to the default behavior of up & down arrows in a vertical menustrip.

    However, if a dropdown is shown ProcessCmdKey no longer applies, resulting
    in the same annoying trap inside the dropdown menu.
    The key-press event of the menustrip also fails to catch key-presses if a dropdown list of an item is shown.

    The workaround (hardly a solution) I came up with, is to have a blank menuitem as root and everything else shifted one level deeper. That is, what used to be the main menu is now itself on a dropdown list.
    The dropdown list's behavior on arrow presses is exactly what I am looking for. However, it doesn't seem to apply easily in the first level collection of a menustrip.

    Any help is greatly appreciated,

    thanasis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width