Verdiğiniz kodun
başına
Kod:
Me.DataGridView1.AllowUserToAddRows = True
Kod:
Me.DataGridView1.AllowUserToAddRows = False
Teşekkürler yadım için.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.DataGridView1.AllowUserToAddRows = True 'Satir ekleme olayini iptal eder ayarlardaki
Dim satır = DataGridView1.Rows.Count - 1
Dim x As Integer = 0
While x < satır - 1
For y As Integer = (satır - 1) To (x + 1) Step -1
If DataGridView1.Rows(x).Cells(0).Value.ToString() = DataGridView1.Rows(y).Cells(0).Value.ToString() Then
DataGridView1.Rows.Remove(DataGridView1.Rows(y))
satır -= 1
End If
Next
x += 1
End While
Me.DataGridView1.AllowUserToAddRows = False
End Sub