Share via


Loading Contacts into ListView Group Item

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

By default, a local client contains at least one contact group. This group is displayed as "All Contacts" when it is the only contact group. When you have defined additional contact groups, this default group is displayed as "Other Contacts". The Office Communicator contact list in the client UI shows all of your contacts not associated with user-defined contact groups under the "Other Contacts" group. This default group actually contains all of your contacts regardless of user-defined group affiliation. When the custom contact list is filled, only those contacts not already added to the ListView as part of a user-defined group are added to the default group.

The contactClass iterates on the IMessengerContact objects in the collection obtained by querying IMessengerGroup::Contacts. The following programming tasks are accomplished by the createGroupListItem(object passedGroup, int groupCount). This method can be found in the complete code listing at the end of the topic.

  • A ListViewGroup item is created with the Name property set using the IMessengerGroup::Name property. If the default contact group is passed as an argument to this method, the groupCount argument is queried. If more than one contact group exists, the ListViewGroup.Name property is "Other Contacts".
  • An IMessengerContacts object is instantiated and filled. This is the collection of individual contacts affiliated with the group processed by this method.
  • The contact collection is iterated over and each contact is added as ListViewItem objects to the ListView if it has not been previously added to another group. Adding a contact to the ListView involves:
    • Casting the IMessengerContact object to a_contact, an IMessengerContactAdvanced implementation. a_Contact makes the presence properties of the contact available.
    • Filling the ToolTipText property of the ListViewItem object from the Presence Note in the IMessengerContactAdvanced::PresenceProperties array of a_Contact.
    • A status string is filled by calling the updateContactList(contactItem, (IMessengerContactAdvanced)groupContact) and returning an English-readable status string from the IMessengerContact::Statusenum value. The status string is created as a subitem of the ListViewItemitemToAdd.
    • A dictionary<int, string> entry is created as an index to be used by the logic under the selectButton. The int key of the dictionary structure is the unique count value associated with the itemToAdd object and the string value is the contact's IMessengerContact::SigninName.

See Also

Concepts

Building a Custom Contact List