[英]How to zoom with scroll wheel
我有一個Windows窗體項目,我想在其中實現滾動。 我試圖使用這個問題的第二個答案
所以現在我的代碼看起來像這樣:
void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta != 0)
{
if (e.Delta <= 0)
{
//set minimum size to zoom
if (pictureBox1.Width < 50)
return;
}
else
{
//set maximum size to zoom
if (pictureBox1.Width > 500)
return;
}
pictureBox1.Width += Convert.ToInt32(pictureBox1.Width * e.Delta / 1000);
pictureBox1.Height += Convert.ToInt32(pictureBox1.Height * e.Delta / 1000);
}
但它只是表現得像這樣
這取決於PictureBox的SizeMode 。 默認情況下,這是枚舉Normal
。 鑒於您的演示,我建議您在調整圖片框大小時使用鼠標滾輪增大和縮小圖像的Zoom
枚舉值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.