Hi all.
I am having alot of trouble getting the ListView to work. I am adding ListViewItems from a Collection of Objects (I have debugged and checked that they are being added to the ListView and they definitely are), but the data isn't showing up in the ListView. What could cause this to happen?
Here's the code:
Private Sub FrmFindContact_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.setListView()
End Sub
Private Sub setListView()
Dim collEnum As IEnumerator
Dim objQuery As New ObjectQuery(GetType(BLL.Contact), "", "")
Dim allContacts As ObjectSet = Global.Manager.GetObjectSet(objQuery)
Me.lvwContacts.Columns.Add("Name", -2, HorizontalAlignment.Left)
Me.lvwContacts.Columns.Add("Telephone", -2, HorizontalAlignment.Left)
Me.lvwContacts.Columns.Add("Email", -2, HorizontalAlignment.Left)
Me.lvwContacts.Items.Clear()
If (Not allContacts Is Nothing) Then
collEnum = allContacts.GetEnumerator()
While (collEnum.MoveNext)
Dim curContact As BLL.Contact = DirectCast(collEnum.Current, BLL.Contact)
Dim objViewItem As New ListViewItem(curContact.displayName)
objViewItem.SubItems.Add(curContact.homeTel)
objViewItem.SubItems.Add(curContact.email)
objViewItem.EnsureVisible()
Me.lvwContacts.Items.Add(objViewItem)
End While
End If
End Sub
I am having alot of trouble getting the ListView to work. I am adding ListViewItems from a Collection of Objects (I have debugged and checked that they are being added to the ListView and they definitely are), but the data isn't showing up in the ListView. What could cause this to happen?
Here's the code:
Private Sub FrmFindContact_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.setListView()
End Sub
Private Sub setListView()
Dim collEnum As IEnumerator
Dim objQuery As New ObjectQuery(GetType(BLL.Contact), "", "")
Dim allContacts As ObjectSet = Global.Manager.GetObjectSet(objQuery)
Me.lvwContacts.Columns.Add("Name", -2, HorizontalAlignment.Left)
Me.lvwContacts.Columns.Add("Telephone", -2, HorizontalAlignment.Left)
Me.lvwContacts.Columns.Add("Email", -2, HorizontalAlignment.Left)
Me.lvwContacts.Items.Clear()
If (Not allContacts Is Nothing) Then
collEnum = allContacts.GetEnumerator()
While (collEnum.MoveNext)
Dim curContact As BLL.Contact = DirectCast(collEnum.Current, BLL.Contact)
Dim objViewItem As New ListViewItem(curContact.displayName)
objViewItem.SubItems.Add(curContact.homeTel)
objViewItem.SubItems.Add(curContact.email)
objViewItem.EnsureVisible()
Me.lvwContacts.Items.Add(objViewItem)
End While
End If
End Sub