我有点迷失,我想在Fast ObjectListView中添加一些项目。我有什么不工作,我似乎无法在网上找到任何vb.net样本
Dim LvItm As BrightIdeasSoftware.OLVListItem = lstMain.Items.Add("title")
With LvItm
.SubItems.Add("name")
.SubItems.Add("last")
.SubItems.Add("phone")
.SubItems.Add("address")
.EnsureVisible()
End With
答案 0 :(得分:3)
ObjectListView与普通的ListView完全不同,通常你不添加单个项目。
简而言之:
- 创建列
- 将创建的列的方面名称设置为对象的属性名称
- 将objectlistview指向对象列表
见下面的例子:
Imports BrightIdeasSoftware
Public Class Person
Public Property name As String
Public Property last As String
Public Property phone As String
Public Property address As String
End Class
Dim LvItm As New Person With {.name = "John",
.last = "Smith",
.phone = "555-69997-44",
.address = "Main Str. 1"}
Dim LvLst As New List(Of Person)
LvLst.Add(LvItm)
ObjectListView1.View = View.Details
ObjectListView1.Columns.Add(New OLVColumn With {.Text = "Name",
.AspectName = "name"})
ObjectListView1.Columns.Add(New OLVColumn With {.Text = "Last Name",
.AspectName = "last"})
ObjectListView1.Columns.Add(New OLVColumn With {.Text = "Phone",
.AspectName = "phone"})
ObjectListView1.Columns.Add(New OLVColumn With {.Text = "Address",
.AspectName = "address"})
ObjectListView1.SetObjects(LvLst)
通过一切设置,您可以将项目添加到列表或以任何方式操作,
再次点击ObjectListView1.SetObjects(LvLst)
以刷新视图。
您还可以直接向ObjectListView添加项目:
Dim p As New Person
p.name = "Steve"
p.last = "Wilson"
p.phone = "777-888-9987"
p.address = "First Str. 1"
ObjectListView1.AddObject(p)
请记住,直接添加的项目未添加到您的列表(人员)