title: Dynamically changing Textbox's AutoComplete List causes AccessViolationException, any advice?
body: <p>My client wanted to have a textbox in the Customer form of the application, which offers the applicable endings to a started street name. He starts to type a street name and the textbox offers a list of streets which start with the char sequence he typed into the textbox.</p>
  
  <p>I said to myself: thats okay, textboxes have the AutoCompleteCustomSource property and even though a list of common street names will be longer than it could be pre-filled on start, i could just hit a database with a query, populate an AutoCompleteStringCollection and show that to the user.</p>
  
  <p>Now here's the thing: if I make the list populate on every keypress/keydown whatever, the program crashes and throws an AccessViolationException.</p>
  
  <p>I've found out that that's because:
  The control is in the middle of showing the AutoComplete list when at the same time it is being modified, resulting in the crash. </p>
  
  <p>When you refresh the Autocomplete List, the control is recreated with new pointers. Keyboard and mouse events (KeyPress, MouseOver, MouseLeave, MouseHover) attempt to reference the old control's pointers which are now invalid in memory causing a memory access violation to occur.</p>
  
  <p>The underlying AutoComplete implementation does not allow for changing the AutoComplete candidate list object once it has been set on a window.  To allow changing the list, WinForms destroys the Edit control or ComboBox and recreates it.  This causes an exception if the underlying control is destroyed while the AutoComplete window is still use it.</p>
  
  <p>I read about this on <a href="http://support.microsoft.com/kb/952544" rel="noreferrer">MSDN</a>, their resolution:</p>
  
  <blockquote>
    <p>Do not modify the AutoComplete candidate list dynamically during key events.</p>
  </blockquote>
  
  <p>I've also tried everything from <a href="http://social.msdn.microsoft.com/Forums/en-EN/winforms/thread/e599b2e2-3cda-43ad-b15f-a69b4fea1a75" rel="noreferrer">this</a> thread</p>
  
  <p>So how could I make this work, if I insist on offering the applicable street names keypress-by-keypress?</p>
  
  <p><strong>Note</strong>: I know that you can do this by creating a custom control and such, <strong>but can it be done with just pure coding wizardry?</strong></p>