If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
row = Me.DataGridView1.Rows(e.RowIndex)
TextBox6.Text = row.Cells("ear_number").Value.ToString
TextBox3.Text = row.Cells("location_of_pig").Value.ToString
ComboBox3.Text = row.Cells("product_used").Value.ToString
ComboBox1.Text = row.Cells("reason_for_treatment").Value.ToString
TextBox4.Text = row.Cells("dose_course_of_treatment").Value.ToString
TextBox2.Text = row.Cells("person_administering").Value.ToString
DateTimePicker1.Text = row.Cells("treatment_date").Value.ToString
End If