اذهب الي المحتوي
أوفيسنا

Remove duplicate items in listview - حذف السطور المكررة في لست فيو


SEMO.Pa3x

الردود الموصى بها

Public Sub RemoveDuplicates(ByVal lstView As ListView)
    Dim itemI, itemJ As ListViewItem
    Dim progress, count As Integer
 
    For i As Integer = lstView.Items.Count - 1 To 0 Step -1
        itemI = lstView.Items(i)
        progress = progress + 1
        ' start one after hence +1
        For z As Integer = i + 1 To lstView.Items.Count - 1 Step 1
            itemJ = lstView.Items(z)
            If itemI.Text = itemJ.Text Then
                'duplicate found, now delete duplicate
                lstView.Items.Remove(itemJ)
                count = count + 1
                Exit For
            End If
        Next z
    Next (i)
End Sub

 

 

الاستدعاء

 

RemoveDuplicates(ListView1)

 

 

طريقة اخرى

 

Function remover(l As ListView) As Boolean
  Dim str As String = " "
  For i As Integer = 0 To l.Items.Count - 1
  Try
  Select Case str.IndexOf("0" & l.Items(i).SubItems(0).Text) = -1
  Case False : l.Items(i).Remove()
  Case True : str &= "0" & l.Items(i).SubItems(0).Text
  End Select
  Catch : End Try
  Next
  Return True
  End Function

 

 

الاستدعاء

 

remover(listview1)

 

تم بحمد الله ، SEMO.Pa3x

:38:

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • اضف...

Important Information