title: Capturing key presses in datagridview cells in c#
body: <p>I'm trying to develop a results box that pops when I start to type in cell in the datagridview, something similar to what Chrome does when you type in the address bar.</p>
  
  <p>I've done most of it, the main problem I'm having is trying to capture and handle arrow key presses (up and down).
  I've caste the cell control to a textbox so I can grab key presses and pass them to the result box so it know what results to display.</p>
  
  <pre><code>tx.PreviewKeyDown += new PreviewKeyDownEventHandler(tx_PreviewKeyDown);
  tx.KeyDown += new KeyEventHandler(tx_KeyDown);
  tx.KeyPress += new KeyPressEventHandler(tx_KeyPress);
  </code></pre>
  
  <p>that works all fine, the problem is, when I press the arrow key down, the tx_PreviewKeyDown captures it, then it disappears until its caught in the datagridview_KeyUp event, by then, its too late and the datagridview has shifted the active cell downwards.</p>
  
  <p>I can handle the event in the tx_PreviewKeyDown and pass that down to move the highlighted value in the result box fine, but what I need to do is prevent it from shifting the active cell downwards into the new row.</p>
  
  <p>I need to be able to cancel the keypress, but the PreviewKeyDown doesn't have a e.Handle flag, either that I need to find what KeyDown event is fired after the tx_PreviewKeyDown but before datagridview_KeyUp event.  Something handles that arrow key, but what?!</p>