如何通过鼠标滚轮进行缩放时调整滚动条位置 [英] How to adjust scroll bar location when zoom by mouse wheel

查看:123
本文介绍了如何通过鼠标滚轮进行缩放时调整滚动条位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

在我的Windows窗体应用程序中,我有 UserControl ,里面有一个 PictureBox

当我在 PictureBox 上使用鼠标滚轮时,它的大小将会改变,而 UserControl 将自动滚动

现在我想要当我使用鼠标滚轮时,调整 UserControl 滚动条来排列鼠标位置

用更好的词语缩放到谷歌地图的鼠标位置!

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!"

推荐答案

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));


这篇关于如何通过鼠标滚轮进行缩放时调整滚动条位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆