tags:

views:

96

answers:

1

Is it possible to hide my custom task pane when opening the file. I tried to add the following command to the OnLoad event, but it looks like the View has not yet been created at this point:

thisXDocument.View.Window.TaskPanes[0].Visible = false;

Is there any other way to do it?
BTW- I am using the 2003 InfoPath API.

A: 

It looks like OnSwitchView is called just after the form is completly loaded. So the View object has been created and you can get access to the task pane. OnSwitchView is called whenever the view changes and we only want to hide the task pane on load, so my code looks like this:

private bool HideTaskPane = true;
...
[InfoPathEventHandler(EventType = InfoPathEventType.OnSwitchView)]
public void OnSwitchView(DocEvent e)
{
    //We only want to perform this once, on startup.
    if (HideTaskPane == true)
    {
        thisXDocument.View.Window.TaskPanes[0].Visible = false;
        HideTaskPane = false;
    }
}
oillio

related questions