AccessTr.neT

Tam Versiyon: Vb.net Datagridview Mükerrerleri Teke Düşürme.
Şu anda arşiv modunu görüntülemektesiniz. Tam versiyonu görüntülemek için buraya tıklayınız.
Ekteki dosyadaki Datagriddeki veriler nasıl benzersiz yapılır?

Kaydetmeye felan gerek yok sadece Datagridde tek olarak görükecek.
Örnek 5 tane a varsa bir tane a olacak.
İnternetten kod buldum çalışmıyor.

Saygılar.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       For i As Integer = 0 To Me.DataGridView1.RowCount - 2

           For j As Integer = i + 1 To Me.DataGridView1.RowCount - 2
               If DataGridView1.Rows(i).Cells(0).Value = DataGridView1.Rows(j).Cells(0).Value Then
                   DataGridView1.Rows.Remove(DataGridView1.Rows(i))

               End If
           Next
       Next
   End Sub
Kod:
Buton 1 kodlarını bunlarla değiştiriniz.

      Dim satır = DataGridView1.Rows.Count - 1
       Dim x As Integer = 0
       While x < satır - 2
           For y As Integer = (satır - 2) 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
Malisef hocam.

Kod çalışınca dosyadaki cc 2 adet çıktı.

Teşekkürler.
Kod:
      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
Ali hocam diğer tarfta yazdığım burdada geçerli.


Teşekkürler.
Galiba sizden başka vb.net anlayan yok burda Img-grin
Ali Can hocam alttaki kodla sorunu hallettim.
Verdiğiniz kodun
 başına
Kod:
Me.DataGridView1.AllowUserToAddRows = True
sonunada
Kod:
Me.DataGridView1.AllowUserToAddRows = False
ekledim.

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