title: C# Scrolling a Panel in windows forms
body: <p>I'm using VS2010, Windows 7</p>
  
  <p>I have a panel with lots of picture-boxes. It has</p>
  
  <pre><code>AutoScroll = true
  </code></pre>
  
  <p>The scroll bars work properly when i drag it, or click on it. However, i want to scroll it with the wheel and arrow keys.</p>
  
  <p>The wheels don't respond at all (and adding event handlers to the form doesn't work, as it ceases firing when i change focus), and to use the arrow keys i'd have to programatically scroll. I tried the following:</p>
  
  <pre><code>panel3.VerticalScroll.Value = panel3.VerticalScroll.Maximum;
  </code></pre>
  
  <p>This doesn't work, the scrollbar barely moves at all. <strong>Maximum</strong> is always 100 for some reason.</p>
  
  <p>What i tried on the wheel problem (doesn't work):</p>
  
  <pre><code>// Fires as long as i don't change focus to anything
  this.MouseWheel += new MouseEventHandler(Panel1_MouseWheel);
  
  private void Panel1_MouseWheel(object sender, MouseEventArgs e)
  {
      panel3.Focus();
  }
  </code></pre>
  
  <p>Thank you.</p>