Enabling/Disabling of a TaskPane

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

Enabling/Disabling of a TaskPane
 
Clark Kent




Posts: 19
Joined: 2008-03-26
Alright, I've got a TaskPaneManager which is housing a TaskPane Collection item which is housing a custom TaskPane that I am loading into Excel. Whenever I start any session of Excel, the Task Pane loads. I've figured out how to "hide it" by setting the enabled property to false:

TaskPaneManager.Items[0].Enabled = false; //this "hides"

However, once I set this to false, I can never get it to show up again using:
TaskPaneManager.Items[0].Enabled = true;


Is this possible to do? Is there another way to do it?

Thanks!
Posted 01 Apr, 2008 14:47:26 Top
Fedor Shihantsov


Add-in Express team


Posts: 1188
Joined: 2005-01-11
Hello Clark,

Use the following code:

ADXExcelTaskPane myTaskPane = null;

if (adxExcelTaskPanesManager1.Items[0].TaskPaneInstance == null) 
{ 
    myTaskPane = adxExcelTaskPanesManager1.Items[0].CreateTaskPaneInstance; 
} 
else
{
    myTaskPane = adxExcelTaskPanesManager1.Items[0].TaskPaneInstance; 
}

if (myTaskPane!= null) 
{
    myTaskPane.Show();
} 
Posted 02 Apr, 2008 05:23:34 Top
Clark Kent




Posts: 19
Joined: 2008-03-26
Fedor, thanks for the response.

To be more specific, I am trying to show/hide my taskpane from my AddinModule class(button click event of a command bar button).

I can't seem to find how to create a new ADXExcelTaskPane object in my code behind. This doesn't work ADXExcelTaskPane myTaskPane = null;
Posted 02 Apr, 2008 10:55:25 Top
Clark Kent




Posts: 19
Joined: 2008-03-26
Nevermind I found it :D
Posted 02 Apr, 2008 10:58:33 Top
Clark Kent




Posts: 19
Joined: 2008-03-26
Fedor, do you know of a way to hide the TaskPane by default? In the codebehind of my TaskPane class, I am trying hide it during the initiliaze component method by doing this.Hide();(in the section where its defining the taskpane)

It compiles fine but when I run the application, the task pane shows up.
Posted 02 Apr, 2008 11:47:48 Top
Fedor Shihantsov


Add-in Express team


Posts: 1188
Joined: 2005-01-11
Clark,

Use the ADXExcelTaskPane.ADXBeforeTaskPaneShow event in the following way:

        private void HideByDefault = true;
        private void ADXExcelTaskPane1_ADXBeforeTaskPaneShow(object sender, AddinExpress.XL.ADXBeforeTaskPaneShowEventArgs e)
        {
            if (HideByDefault)
            {
                this.Visible = false;
                HideByDefault = false;
            }
        }


Also you can use the ADXExcelTaskPanesManager.ADXBeforeTaskPaneInstanceCreate event:

        private void HideByDefault = true;
        private void adxExcelTaskPanesManager1_ADXBeforeTaskPaneInstanceCreate(object sender, AddinExpress.XL.ADXBeforeTaskPaneInstanceCreateEventArgs e)
        {
            if (HideByDefault)
            {
                e.Cancel = true;
                HideByDefault = false;
            }
        }

Posted 03 Apr, 2008 06:27:49 Top
Clark Kent




Posts: 19
Joined: 2008-03-26
Fedor, you are the man! Thank you! I didn't realize that the TaskPane object had so many events!

What a great product!
Posted 03 Apr, 2008 10:29:30 Top