【发布时间】:2017-06-29 16:45:46
【问题描述】:
我正在编写一个 vb/windows 形式的工具,它将删除远程计算机上的用户配置文件。除了显示已删除的计算机名称和配置文件外,它的效果很好。
当我尝试 ObjectListView 时,它会在第一行显示信息,并为每台计算机覆盖它,并在每台计算机上删除每个配置文件。这是我遇到问题的代码部分......
Public Class PC
Public Property Computer_Name As String
Public Property Profile_Name As String
End Class
-
For Each objProfile In colProfiles
Dim dtmLastUseTime = CDate(Mid(objProfile.LastUseTime, 5, 2) & "/" &
Mid(objProfile.LastUseTime, 7, 2) & "/" & VB.Left(objProfile.LastUseTime, 4) _
& " " & Mid(objProfile.LastUseTime, 9, 2) & ":" &
Mid(objProfile.LastUseTime, 11, 2) & ":" & Mid(objProfile.LastUseTime,
13, 2))
If DateDiff("d", dtmLastUseTime, d1) > intMaxProfileAge Then
usrPath = objProfile.localpath
rowInfo2 = usrPath
Dim LvItm As New PC With {.Computer_Name = rowInfo1, .Profile_Name = rowInfo2}
Dim LvLst As New List(Of PC)
LvLst.Add(LvItm)
ObjectListView1.SetObjects(LvLst)
objProfile.Delete_
End If
Next
【问题讨论】:
-
连一排都没有?因为在您的代码中,您每次迭代都会为当前项目创建一个新列表。
-
SetObjects() 在添加新项目之前肯定会清除列表。
标签: vb.net objectlistview