DevComponents.com

How to scroll SideBar using MouseWheel

Code below shows an example of how to scroll current SideBarPanel using MouseWheel:

private void frm_Load(object sender, EventArgs e)
        {
            sideBar1.MouseMove += new MouseEventHandler(sideBar1_MouseMove);
            sideBar1.MouseWheel += new MouseEventHandler(sideBar1_MouseWheel);
      }

        void sideBar1_MouseMove(object sender, MouseEventArgs e)
        {
            sideBar1.Focus();
        }

        void sideBar1_MouseWheel(object sender, MouseEventArgs e)
        {
            if (e.Delta < 0)
            {
                if (sideBar1.ExpandedPanel.TopItemIndex < sideBar1.ExpandedPanel.SubItems.Count - 1)
                    sideBar1.ExpandedPanel.TopItemIndex = sideBar1.ExpandedPanel.TopItemIndex + 1;
            }
            else
            {
                if (sideBar1.ExpandedPanel.TopItemIndex > 0)
                    sideBar1.ExpandedPanel.TopItemIndex = sideBar1.ExpandedPanel.TopItemIndex - 1;
            }
        }

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favoritesAdd to favorites

User Opinions (0 votes)

No users have voted.

How would you rate this answer?

Helpful
Not helpful
Thank you for rating this answer.

Related Questions

No related questions were found.

Attachments

No attachments were found.