Click here to Skip to main content
15,906,081 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello
In my windows form app, i have UserControl and inside it there is a PictureBox.
when i use mouse wheel on the PictureBox the size of it will changed and the UserControl will auto scroll
Now i want when i use the mouse wheel, adjust the UserControl scroll bars to arrange the mouse location
in better words "zoom to the mouse location like Google Maps!"
Posted

1 solution

C#
float sv = (float)testPnl1.VerticalScroll.Value / (float)testPnl1.VerticalScroll.Maximum;
float sh =                                                  (float)testPnl1.HorizontalScroll.Value/(float)testPnl1.HorizontalScroll.Maximum;
           
ImageWidth += zoom;

Pnl.AutoScrollPosition = new Point((int)(Pnl.HorizontalScroll.Maximum * sh), (int)(Pnl.VerticalScroll.Maximum * sv));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900