Freigeben über


Modify Form Region Properties at Run Time

An Outlook Form Region item maintains a set of properties that affect the way it appears in Outlook.

These properties specify details such as the type of form region you want to create, the message classes of Inspectors that will display the form region, and the label that will identify the form region in Outlook.

Setting these properties at design-time is relatively easy. Use the New Outlook Form Region wizard or expand the Manifest node in the Properties window to access the form region properties.

However, setting them at run time is less intuitive. I cannot think of a scenario where this would be useful, but I am sure there are plenty. Therefore, if you want to set the properties of a form region at run time, use the Manifest object in the constructor of the form region. The following example illustrates this.

public FormRegion1()

        {

      InitializeComponent();

            this.Manifest.FormRegionType = Microsoft.Office.Tools.Outlook.FormRegionType.Adjoining;

            this.Manifest.ExactMessageClass = true;

            this.Manifest.ShowInspectorCompose = false;

            this.Manifest.Title = "Updated Title";

            #region VSTO Designer generated code

            this.FormRegionInitializing += new EventHandler<OutlookTools.FormRegionInitializingEventArgs>(FormRegion1.FormRegion1_FormRegionInitializing);

            #endregion

Why Can’t I do this in the FormRegionInitializing or FormRegionShowing Event Handler?

By the time these events are raised, Outlook has already requested an XML file representing these properties from the Outlook add-in. Once Outlook has this information, the properties of the Manifest object become read-only.

You can’t even see the Manifest object in the FormRegionIntializing event handler. You can see it in the FormRegionShowing event handler, but you cannot change the values.

What is the Purpose of FormRegionIntializing Event Handler?

The FormRegionIntializing event handler is more or less your opportunity to display or not display a form region based upon some criteria. You can add code to this event handler to evaluate some condition and then use “e.Cancel” if you do not want the form region to appear. If you want to change the form region properties that appear beneath the Manifest node in the Properties window, you can use the constructor.

Note: that this behavior is likely to change for Beta 2 and beyond.

Norm Estabrook

  

This posting is provided "AS IS" with no warranties, and confers no rights.

Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm.