Mouse wheel scrolling Toolstrip menu items

后端 未结 4 1393
梦如初夏
梦如初夏 2021-01-14 13:48

I have some menus that contain many menuitems. Mouse wheel doesn\'t scroll them. I have to use the keyboard arrows or click the arrows at top and bottom. Is it possible to u

4条回答
  •  温柔的废话
    2021-01-14 14:11

    This is very simply using a submenu (ToolStripMenuItem) of the context menu :

    Assuming using a form1 (or UserControl) and a contextMenuStrip1 :

    private void form1_Load( object sender , EventArgs e )
    {
        //this.MouseWheel -= When_MouseWheel;
        this.MouseWheel += When_MouseWheel;
    }
    void When_MouseWheel( object sender , MouseEventArgs e )
    {
        if ( this.contextMenuStrip1.IsDropDown ) {
             //this.Focus();
             if ( e.Delta > 0 ) SendKeys.SendWait( "{UP}" );
             else SendKeys.SendWait( "{DOWN}" );         
        }
    }
    

提交回复
热议问题