Loading Contact Groups

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.

The following code snippet from the complete code sample iterates on a collection of IMessengerGroup objects. Each individual group is passed into the createGroupListItem(IMessengerGroup) and a ListViewGroup item is returned. The new ListViewGroup, groupItem is added to the Items collection of the ListView, contactListView.

contactGroups = (IMessengerGroups)communicator.MyGroups;
 if (contactGroups != null)
 {
    foreach (IMessengerGroup contactGroupItem in contactGroups)
    {
      ListViewGroup newGroup = createGroupListItem(contactGroupItem);
      contactListView.Groups.Add(newGroup);
      ListViewItem groupItem = new ListViewItem(newGroup);
      contactListView.Items.Add(groupItem);
    }
 }

See Also

Concepts

Building a Custom Contact List