【问题标题】:How to zoom with scroll wheel如何使用滚轮缩放
【发布时间】:2014-07-26 13:36:21
【问题描述】:

我有一个 Windows 窗体项目,我想在其中实现滚动。我试图使用this question的第二个答案

所以现在我的代码如下所示:

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

但它只表现得像this

【问题讨论】:

    标签: c# visual-studio scroll zooming mousewheel


    【解决方案1】:

    这取决于您的 PictureBox 的SizeMode。默认情况下,这是枚举 Normal。鉴于您的演示,我建议您使用 Zoom 枚举值,以便在调整图片框大小时使用鼠标滚轮放大和缩小图像。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-20
      • 2014-04-05
      • 2012-07-18
      • 1970-01-01
      相关资源
      最近更新 更多