masj78 Posted August 27, 2003 Posted August 27, 2003 (edited) Please help someone! I am trying to get a display of the emails in my Inbox in my application using a ListView. I can get the first item and subitem in my Loop cycling through the Inbox. However I cannot get any more subItems to print in the remaining collumns. If I do I get this error message: A first chance exception of type 'System.Reflection.AmbiguousMatchException' occurred in microsoft.visualbasic.dll Additional information: No accessible overloaded 'ListViewSubItemCollection.Add' can be called without a narrowing conversion. My code is as follows: VB.NET: Dim objMessage As MAPI.Message Dim lstStuff As New ListViewItem Dim count As Integer With ListView1.Items For Each objMessage In gobjSession.Inbox.Messages count = count + 1 lstStuff = .Add(objMessage.Size) With lstStuff .SubItems.Add(objMessage.Subject) .SubItems.Add(objMessage.TimeReceived) ' error if add this extra line End With Next End With End Sub Cheers! Edited August 27, 2003 by masj78 Quote
masj78 Posted August 29, 2003 Author Posted August 29, 2003 I have solved this in another forum. The ListView does not allow different variable types to co-exist together. The only variable type accepted is 'String'. The first item and subitem are both of type String. The 'time received' subitem I was trying to add is of type 'Variant'. What was needed was to cast it to a String, which is of course simple; As follows: .SubItems.Add(objMessage.TimeReceived.ToString) Job Done! Quote
Recommended Posts