Solved

Scrolling with mousewheel doesn't scroll a FlowLayoutPanel

Posted on 2009-04-10
3
2,655 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Memory Usage 2 50
Unable to upgrade to .Net 4.6.2 on Server 2012r2 2 43
DataGridView Events ? 3 37
Visual Studio 2015 Source Code Control 10 34
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now