Skip to main content


The DisplayContact method displays a Contact instance's information in the Edit Contact Information section of the GUI. This method is invoked by the event-handler for tree selection events: treeView1_AfterSelect. The method does the following:

  1. Accepts a single argument of type string. This argument represents the object ID of the Contact to be displayed.

  2. Opens the Contact instance with the specified ID and assigns the instance to the class variable curContact. Note that status, a variable of type CacheStatus is passed to Open as an out parameter. After the method executes this variable contains any status information generated by the attempt to open the object.

  3. If the status indicates that something has gone wrong in the attempt to open the object, DisplayContact displays a message.

  4. If the status indicates that nothing has gone wrong opening the object, DisplayContact updates the GUI elements to display the Contact instance's information.

Here is the method. Add the body of the method to the DisplayContact stub in PhoneFormObj.cs.

private void DisplayContact(string id)
 curContact = Contact.OpenId(cnCache, id, out status);
 if (!status.IsOK)
   txtConId.Text = curContact.Id();
   txtConName.Text = curContact.Name;
   comboBox1.SelectedItem = curContact.ContactType;

FeedbackOpens in a new tab