共用方式為


HOW TO:防止 Outlook 顯示表單區域

更新:2007 年 11 月

適用於

本主題中的資訊僅適用於指定的 Visual Studio Tools for Office 專案和 Microsoft Office 版本。

專案類型

  • 應用程式層級專案

Microsoft Office 版本

  • Outlook 2007

如需詳細資訊,請參閱依應用程式和專案類型提供的功能

在某些情況下,您可能不想讓 Microsoft Office Outlook 顯示特定項目的表單區域。例如,連絡人項目未包含公司地址時,您便可以不讓地圖上標記公司位置的表單區域顯示。

防止 Outlook 顯示表單區域

  1. 開啟要修改之表單區域的程式碼檔案。

  2. 展開 [表單區域 Factory] 程式碼區域。

  3. 將程式碼加入至 FormRegionInitializing 事件處理常式,以便將 FormRegionInitializingEventArgs 類別的 Cancel 屬性設為 true。

在這個範例中,如果連絡人項目未包含地址,則 Cancel 屬性會設為 true,且表單區域就不會顯示。

範例

Private Sub MapItFactory_FormRegionInitializing(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs) Handles Me.FormRegionInitializing

    Dim myItem As Outlook.ContactItem = CType(e.OutlookItem, Outlook.ContactItem)

    If Not (myItem Is Nothing) Then
        If Not (myItem.BusinessAddress Is Nothing) AndAlso myItem.BusinessAddress.Trim().Length > 0 Or (Not (myItem.HomeAddress Is Nothing) AndAlso myItem.HomeAddress.Trim().Length > 0) Or (Not (myItem.OtherAddress Is Nothing) AndAlso myItem.OtherAddress.Trim().Length > 0) Then
            Return
        End If
    End If

    e.Cancel = True

End Sub
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;
}

請參閱

工作

逐步解說:設計 Outlook 表單區域

HOW TO:存取顯示表單區域的 Outlook 項目

HOW TO:在 Outlook 增益集專案中加入表單區域

逐步解說:設計 Outlook 表單區域

逐步解說:匯入在 Outlook 中設計的表單區域

概念

建立 Outlook 表單區域