title: VB.Net, ComboBox when lostfocus => Error : invalid argument value of 0 is not valid for index
body: <p>I m working on a VB.Net using Framework 3.5, i need a specific autocomplete for the combo, in that way i m using a BindingSource that can i use its "Filter" Property</p>
  
  <pre><code>    Dim m_bsCommune As New BindingSource
      m_bsCommune.DataSource = m_dtCommune
      cboCommune.DataSource = m_bsCommune
  </code></pre>
  
  <p>Then, i implemented the event "TextUpdate" of combo :</p>
  
  <pre><code>    Private Sub cboCommune_TextUpdate(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboCommune.TextUpdate
  
      Dim cboValue As String = cboCommune.Text
  
      m_bsCommune.Filter = String.Format("CODE_COM Like '%{0}%'", cboCommune.Text)
      cboCommune.Text = cboValue
      cboCommune.Select(cboCommune.Text.Length, 0)
      cboCommune.DroppedDown = True
  
  End Sub
  </code></pre>
  
  <p>The filter works fine, but in the case i tape a value that does not exist in the combo, and when i try to move to another control, or i click outside the combo i get the error :</p>
  
  <blockquote>
    <p>"invalid argument value of 0 is not valid for index"</p>
  </blockquote>
  
  <p>I tried to manage this error on the events "LostFocus, GotFocus" but the error is generated befor those two events !</p>
  
  <p>Thanks for your help</p>