mitchel c
Posts: 20
Joined: 2006-05-07
|
How can I show/hide a panel from the Selection change event? I want to only show it for some mail items based on a special header...
Thanks! |
|
Fedor Shihantsov
Guest
|
Mitchel,
Please, add Events (AddinExpress.MSO.ADXOutlookAppEvents) component to AddinModule.
And use the following code in ExplorerSelectionChange handler.
private void adxOutlookEvents_ExplorerSelectionChange(object sender, object explorer)
{
Outlook.Selection selection = null;
Outlook.MailItem mailItem = null;
try
{
selection = (explorer as Outlook.Explorer).Selection;
if (selection.Count == 1)
{
if (selection[1] is Outlook.MailItem)
{
mailItem = selection[1] as Outlook.MailItem;
adxOlFormsManager1.Items[0].Enabled = (mailItem.Subject == "MySubject");
}
}
}
finally
{
if (selection != null)
Marshal.ReleaseComObject(selection);
if (mailItem != null)
Marshal.ReleaseComObject(mailItem);
}
}
Note, this will result in creation of a new form instance for every SelectionChange event. So, you need to keep your data (if any) somewhere else. |
|