我做了一个类来将项目添加到Listview
我的Home Form
. 类代码如下:
Public Class ActivityLogEngine
Public Sub LogActivity(ByVal Category As String, ByVal Description As String)
Dim item As New ListViewItem
Dim str(1) As String
Dim itm As ListViewItem
str(0) = "[" & Category & "]"
str(1) = Description
itm = New ListViewItem(str)
Home.ActivityList.Items.Add(itm)
End Sub
End Class
所以你可以看到,当我创建一个实例ActivityLogEngine
并使用LogActivity
sub 时,它会将Category
和Description
字符串写入我的Home Form
. 但是,当我使用代码时:
Dim engine As ActivityLogEngine = New ActivityLogEngine
engine.LogActivity("Server", "Files loaded & connected to server")
它不会将这些行写入我的Listview
. 如果这有什么不同,我会DetailsView
在我的Listview
.
有什么建议么?