title: How to check if a value already exists in DataGridView?
body: <p>I am trying to check each row in the DataGridView whenever I add an Item in order to avoid duplicates. But my code only allows me to check the first data I added.</p>
  
  <p>Here is my code given below:</p>
  
  <pre><code>For Each row In BarcodePrintListGrid.Rows
  
      If Label44.Text = row.Cells("Barcode ID").Value Then
          MetroMessageBox.Show(Me, "Item Already Added", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  
          Label47.Text = "None"
          Label44.Text = "None"
          Label42.Text = "None"
          Label31.Text = "None"
          Label40.Text = "0"
          TextBox1.Clear()
  
          Exit For
  
      Else
          BarcodePrintListGrid.Rows.Add(Label47.Text, Label44.Text, Label42.Text, Label31.Text, Label40.Text, 1)
  
          MetroMessageBox.Show(Me, "Item Added to List", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
  
          Label47.Text = "None"
          Label44.Text = "None"
          Label42.Text = "None"
          Label31.Text = "None"
          Label40.Text = "0"
          TextBox1.Clear()
  
          Exit For
      End If
  
  Next
  </code></pre>