none
How to Minimize/Collapse outlook-addin custom task pane as same as Folder Pane ? RRS feed

  • Question

  • Summary:

    I have created VSTO outlook addin project. Added user control and other controls. I am able to show/hide custom task pane by clicking on button from Ribbon. I want to minimize and expand it as same as outlook built in Folder Pane does at right side. I am not able to minimize or collapse it as Folder Pane does.

    What I did: 

    I have added code to change width of task pane but there are two buttons "Task Pane Options" and "Close X" is not letting it to look same as minimized folder pane.

    From This Add in Class

      public CustomTaskPane custTaskPane;
            public bool isTaskPaneCollapse = false;

            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                TaskPane tpControl = new TaskPane();
                tpControl.BackColor = Color.White;
                
                custTaskPane = this.CustomTaskPanes.Add(tpControl, " ");
                    custTaskPane.Visible = true;
                custTaskPane.Width = 370;
                
                custTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
            }

    From another button to minimize (changing width)
      private void Button_Click(object sender, RoutedEventArgs e)
            {
                Globals.ThisAddIn.isTaskPaneCollapse = true;
                Globals.ThisAddIn.custTaskPane.Width = 20;
            }

    What is the right way of doing it? how to implement minimize and expand functionality for custom task pane

    Wednesday, July 10, 2019 7:59 AM

All replies

  • The CustomTaskPane interface doesn't provide anything for that out of the box. You may try to implement the required functionality by setting the custom task pane size properties. Depending on the layout (the Dock position) you can use the Height and Width properties.

    Width

    Do not use the Width property if the custom task pane is docked to the top or the bottom of the document window. If the DockPosition property is Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionTop or Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionBottom, the Width property returns 0 and throws a COMException if you try to set it.

    The maximum width depends on the dock position. When the custom task pane is docked to the left or right of the document window, the maximum width is approximately half the width of the screen. When the custom task pane is floating, there is no maximum width.

    The minimum width depends on several factors, and can change in future releases of Microsoft Office. If you try to set the Width property to a value that is less than the minimum width, the application will automatically reassign the Width property to the minimum width.

    Height

    Do not use the Height property if the custom task pane is docked to the left or the right of the document window. If the DockPosition property is Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight or Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft, the Height property returns 0 and throws a COMException if you try to set it.

    The maximum height depends on the dock position. When the custom task pane is docked to the top or bottom of the document window, the maximum height is approximately half the height of the screen. When the custom task pane is floating, there is no maximum height.

    The minimum height depends on several factors, and can change in future releases of Microsoft Office. If you try to set the Height property to a value that is less than the minimum height, the application will automatically reassign the Height property to the minimum height.

    Also, you may consider using Advanced Outlook view and form regions. They provide the required functionality out of the box.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, July 10, 2019 8:31 AM