title: VB.NET ComboBox Verify if Value Exists
body: <p>I am currently working on an application that was coded in VB. I am making modifications and adding features to it. </p>
  
  <p>The issue I have is that I want to run a verification check for the ComboBox based on if the value exists before I attempt to select it. </p>
  
  <p>The combo box is populated from a sql query with a dictionary data source      </p>
  
  <pre><code>Dim TimerComboSource As New Dictionary(Of String, String)()
  TimerComboSource.Add(varSQLReader("ID").ToString, varSQLReader("Name").ToString)
  'Binds the values to the comboboxes
  cmbTimer.DataSource = New BindingSource(TimerComboSource, Nothing)
  cmbTimer.DisplayMember = "Value"
  cmbTimer.ValueMember = "Key"
  </code></pre>
  
  <p>I select a value from a different ComboBox which is populated with a different SQL Query/SQL Table.</p>
  
  <p>When I select the second ComboBox value, the table it comes from contains the ID of the first ComboBox. I want to verify if the Value Exists in the first ComboBox before I select it.</p>
  
  <p>The following does not work:</p>
  
  <pre><code>If cmbTechnician.Items.Contains(varSQLReader("Tech_ID").ToString) Then
      cmbTechnician.SelectedValue = varSQLReader("Tech_ID").ToString
  End If
  </code></pre>
  
  <p>Is there a specific way in VB to make this work without it being overly complicated? The other work around would to make a more complicated SQL query but I rather not do that if there's a simpler way.</p>