منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
إزالة العناصر من listview - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : إزالة العناصر من listview (/showthread.php?tid=17891)



إزالة العناصر من listview - Mohamed20 - 02-11-16

كيف يمكن إزالة عدد من العناصر من listview   
مثال عندى listview يوجد بها بعد من العناصر و عندى مجموعة من العناصر 

كود :
Dim Names As String()
Dim id As String()
            Dim nameandid As New Dictionary(Of UInt32, String)
هذه العناصر متغيره اريد اذالتها  هذه العناصر من listview ثم اضافة العناصر الجديدة

كود :
       Try
           Dim Names As String()
           Dim id As String()
           Dim nameandid As New Dictionary(Of UInt32, String)
           'remove old

           For Each Itemre In Names
               If Not Itemre = String.Empty Then
                   ListView1.Items.RemoveAt(Itemre)
                   nameandid.Remove(nameandid(Itemre))
               End If
           Next

           'change text
           Names = {"vb4arb", "ssssss"}
           id = {"1231", "789542"}

           'add new
           For Each Item In Names
               ListView1.Items.Add(Item).SubItems.Add(nameandid(ListView1.Items.Count - 1))
               nameandid.Add(nameandid(Item.Count - 1), Item)
           Next
       Catch ex As Exception

       End Try

المشكة ان لا يتم الاضافة او يتم الاضافة بعض الاحيان لاكن اول item فقط