title: WinForms listbox keydown event won't fire
body: <p>I am trying to make a WinForm ListBox in which you can loop trough using the arrow keys. I also have two buttons on which you can click to go up and down the list. The buttons do produce the desired effect. The problem is that the ListBox's keyDown event is never triggered</p>
  
  <pre><code>    public MainForm()
      {
          InitializeComponent();
          if (this.clipboardHistoryList.Items.Count &gt; 0)
              this.clipboardHistoryList.SetSelected(0, true);
          clipboardHistoryList.Select();
      }
  
     private void goUpButton_Click(object sender, EventArgs e)
      {
          goUpList();
      }
  
      private void goDownButton_Click(object sender, EventArgs e)
      {
          goDownList();
      }
  
      private void goDownList()
      {
          if (clipboardHistoryList.SelectedIndex == clipboardHistoryList.Items.Count - 1)
          {
              clipboardHistoryList.SetSelected(0, true);
          }
          else
          {
              clipboardHistoryList.SetSelected(clipboardHistoryList.SelectedIndex + 1, true);
          }
      }
  
      private void goUpList()
      {
          if (clipboardHistoryList.SelectedIndex == 0)
          {
              clipboardHistoryList.SetSelected(clipboardHistoryList.Items.Count - 1, true);
          }
          else
          {
              int l_currentlySelected = clipboardHistoryList.SelectedIndex;
              clipboardHistoryList.SetSelected(l_currentlySelected - 1, true);
          }
      }
  
      private void clipboardHistoryList_KeyDown(object sender, KeyEventArgs e)
      {
          if (e.KeyCode == Keys.Up)         //Brekpoint is never reached
          {
              goUpList();
          }
          else if (e.KeyCode == Keys.Down)
          {
              goDownList();
          }
      }
  </code></pre>
  
  <p>I have put the MainForm's keypreview proprety to true.</p>
  
  <p>The arrow keys do work by default on a listbox but they won't let you go from last to first element if you press the down arrow on the last element --hopes this makes sense.</p>
  
  <p><strong>EDIT</strong>
  I have seen on <a href="http://Perform%20special%20input%20or%20navigation%20handling%20on%20a%20control.%20For%20example,%20you%20want%20the%20use%20of%20arrow%20keys%20in%20your%20list%20control%20to%20change%20the%20selected%20item.%09Override%20ProcessDialogKey" rel="nofollow noreferrer">Microsoft's documentation</a> that I need to override the <code>ProcessDialogKey</code> method but I am not exactly sure of what I need to do.</p>
  
  <blockquote>
    <p>Perform special input or navigation handling on a control. For example, you want the use of arrow keys in your list control to change the selected item.  Override ProcessDialogKey</p>
  </blockquote>
  
  <p>Is there already a built-in way to enable this behaviour?</p>
  
  <p>What did I miss?</p>
  
  <p>Thanks!</p>