Solved

Scrolling with mousewheel doesn't scroll a FlowLayoutPanel

Posted on 2009-04-10
3
2,712 Views
Last Modified: 2013-12-17
(C# .NET 2.0) I have a form with a TabControl, and inside many of the tabs is a FlowLayoutPanel containing multiple images. I am unable to scroll up/down these FlowLayoutPanels with the mouse wheel - I can only do it by dragging the scrollbar at the side which is a bit of an inconvenience. How can I set some sort of method to recognise the wheel being scrolled if the mouse is within the area of the FlowLayoutPanel, and if so move the panel up and down?

Also I would like to add that the mouse does successfully scroll the panel on my laptop using the scroll side of the touchpad, yet if I plug a mouse into the laptop and use its wheel it doesn't scroll with it, so the panel is obviously only responding to certain mouse drivers it seems. Any help would be appreciated.
0
Comment
Question by:smickell
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24120412
You need to give your FlowLayoutPanel focus:

        private void flowLayoutPanel1_MouseEnter(object sender, EventArgs e)
        {
            flowLayoutPanel1.Focus();
        }

You may need to do the same thing with the PictureBoxes (I assume).  That is to say, on MouseEnter() for the PictureBoxes, give focus to "flowLayoutPanel1".
0
 

Author Comment

by:smickell
ID: 24121641
As easy as that! I didn't think that would be needed because I already tried just clicking on the FLP, keeping the mouse in that spot (so it still had 'focus') and scrolling and it made no difference.
I didn't seem to need to create an additional event for the pictureboxes, the FLP is still scrollable even when hovered over the picturebox.
Many thanks Idle_Mind and have yourself a nice 500pts.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24122165
It just depends on how much "margin" there is between the edge of your FlowLayoutPanel and the PictureBoxes.  If the margin is very small and the user is moving the mouse fast...then the MouseEnter() event might not fire for the FlowLayoutPanel (it might instead go directly to the PictureBox).
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question