Item Collection and a ListView (Vb.Net)

C

Craig Buchanan

I am using a ListView with checkboxes as a metaphor for working with a
collection (MapiFolder.Items) of ContactItems in a Wizard that I am
building--I want to make sure that I'm using 'best practices' when 'binding'
the two objects together.

I use a form-level property to store the collection of ContactItems which
have been filtered according to a user's input. I manually bind selected
properties of (i.e. create ListViewItem and SubItems) this collection to the
ListView, as there isn't a way to do this declaratively. I use the EntryId
as the Tag for the ListViewItem.

Currently, if I need to make change to a ContactItem that has been created
in the ListView (e.g. changing the email address), I use the EntryID to
locate the ContactItem in the MailFolder.Items collection using the Find
method.

It appears that the Index to the MapiFolder.Items collection is the
MailItem's (ContactItem) Subject property. I would use this, but I'm a bit
concerned that two ContactItems have the same Subject (I live in MN and
there are a lot of Andersons...).

Is there a better pattern to use?

Thanks for your time,

Craig Buchanan
 
K

Ken Slovak - [MVP - Outlook]

Using EntryID in a Find or Restrict is not supported. If you already have
EntryID just that to get the item directly: NameSpace.GetItemFromID().

In a contact Subject is usually FullName. As an index into an Items
collection it's not valid if you mean like the 34th item in the collection.
 
C

Craig Buchanan

Ken-

If I use GetItemFromId, then there's no value in keeping the Restrict[ed]
collection. I guess I figured that accessing the Restrict[ed] collection by
the Subject would be more efficient than GetItemById().

Thanks for your [continued] help.

Craig Buchanan
www.cogniza.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top