2014-04-05 2 views
0

약간 길어졌고 일부 항목을 Fast ObjectListView에 추가하고 싶습니다. 내가 가지고있는 것은 작동하지 않습니다, 나는 정상 ListView에 완전히 다른 작동 일반적으로 개별 항목을 추가 해달라고 ObjectListView vb.net 샘플ObjectListView 항목을 추가하는 중

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 

답변

3

온라인 아무것도 찾을 수가 기운 다. 한마디로

:
- 열을 만들
-

는 아래의 예를 참조 객체 목록에 포인트 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) 

을 항목은 직접 코드가 작동

+0

감사 (사람의) 목록에 추가되지 않은 추가 된 기억, 나는 약간의 문제를 가지고있다 이 코드를 사용하여 이미 정의 된 열이 4 개의 원본 대신 8 개의 열로 끝납니다. 어떻게 작동합니까? – XK8ER

+0

내 코드에서 열이 추가 된 모든 줄을 제거하십시오. 'ObjectListView1.Columns.Add (새 OLVColumn'등 – Lukas2

+0

완벽한, 고마워 – XK8ER

관련 문제