Dynamically show/hide existing Ribbon Tab

Add-in Express™ Support Service
That's what is more important than anything else

Dynamically show/hide existing Ribbon Tab
 
Mike Medved




Posts: 41
Joined: 2010-10-19
Doing development in C#, VS 2010. Add-in Express 2010. Currently testing on Outlook 2010 but will need it to work on 2003 and up.

I need to Show/Hide the built in HOME tab at runtime, depending on which folder is being viewed. I tried implementing the suggestion at http://www.add-in-express.com/forum/read.php?FID=1&TID=7637&MID=38369

However it does not seem to be working as expected. Whatever I set the Visible property to the first time the FolderSwitch event occurs is what it sticks to. Subsequent changes to the property seem to be ignored, even if the RibbonUI is invalided.

Here is a sample of the code:

private void AddinModule_OnRibbonLoaded(object sender, IRibbonUI ribbon)
{
    theRibbonUI = ribbon;

}
private void adxOlFormsManager1_ADXBeforeFolderSwitch(object explorerObj, AddinExpress.OL.ADXOlFormsCollectionItem SrcItem, object SrcFolder, AddinExpress.OL.ADXOlFormsCollectionItem DstItem, object DstFolder)
{
    string sName = (DstFolder as Outlook.MAPIFolder).Name;

	// Default home ribbon to be hidden for the TEST folder
    showHomeRibbon = (sName != "TEST Tasks");
}
private void adxOutlookEvents_ExplorerFolderSwitch(object sender, object explorer)
{

    adxRibbonTaskListExplorer.Visible = showHomeRibbon;

    try
    {
        theRibbonUI.InvalidateControl(adxRibbonTaskListExplorer.Id);
    }
    catch (Exception) { }
}


Could you let me know what I am doing wrong?
Posted 23 Nov, 2010 11:31:07 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Mike,

Please note that the Tab activation feature was added in Office 2010. For more information please have a look at the Ribbon Extensibility in Office 2010: Tab Activation and Auto-Scaling article in MSDN.

FYI Please have a look at the ActivateRibbonTabMso method of the add-in module class.
.NET, Extended MAPI, Windows Phone & RT
Posted 23 Nov, 2010 12:01:26 Top
Jerry Medved




Posts: 1
Joined: 2010-10-19
Eugene,

If I understand it correctly, Activate is just for bringing the tab to the foreground. That is not the issue for me. I need to either hide it entirely or show it, and leave it to the user to actually select it. And would need to do that on both 2007 and 2010.

I can show or hide the tab, but only once. Once I hide it, cannot show it again. Thats the problem.
Posted 23 Nov, 2010 12:23:15 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Jerry,

There is no any way to show or hide a ribbon tab programatically (at runtime). Please mote that Ribbon UI is a static thing. For more information please have a look at the similar forum thread.
.NET, Extended MAPI, Windows Phone & RT
Posted 24 Nov, 2010 03:33:50 Top
Mike Medved




Posts: 41
Joined: 2010-10-19
hmm, I see. I thought you could still show/hide the tab dynamically, like you can with buttons and groups.

Thanks for the help.
Posted 24 Nov, 2010 07:25:12 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Mike,

This is a bug. I have just filed the mentioned issue in our bug-tracking system under #2109. We will publish a new build of Add-in Express 2010 on our web site soon.

Thank you for pointing this to me.
.NET, Extended MAPI, Windows Phone & RT
Posted 24 Nov, 2010 11:02:12 Top