Export (0) Print
Expand All

How to: Prevent Outlook from Displaying a Form Region

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Application-level projects

Microsoft Office version

  • Outlook 2007

For more information, see Features Available by Application and Project Type.

There might be situations in which you do not want Microsoft Office Outlook to display a form region for a particular item. For example, if a contact item does not contain a business address, you can prevent a form region that shows the location of the business in a map from appearing.

To prevent Outlook from displaying a form region

  1. Open the code file for the form region you want to modify.

  2. Expand the Form Region Factory code region.

  3. Add code to the FormRegionInitializing event handler that sets the Cancel property of the FormRegionInitializingEventArgs class to true.

In this example, if the contact item does not contain an address, the Cancel property is set to true, and the form region does not appear.

private void MapItFactory_FormRegionInitializing(object sender,
    Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)
{
    Outlook.ContactItem myItem = (Outlook.ContactItem)e.OutlookItem;

    if (myItem != null)
    {
        if ((myItem.BusinessAddress != null &&
                myItem.BusinessAddress.Trim().Length > 0) ||
            (myItem.HomeAddress != null && 
                myItem.HomeAddress.Trim().Length > 0) ||
            (myItem.OtherAddress != null && 
                myItem.OtherAddress.Trim().Length > 0))
        {
            return;
        }
    }

    e.Cancel = true;
}

Community Additions

ADD
Show:
© 2015 Microsoft