1
votes

I am creating an PowerPoint VSTO addin and that adds content to the active slide. When that content gets selected i want to show a settings task pane on the right side of the screen. I know that this can easily be done with an office web add-in but is it possible to do it in a VSTO add-in?

How can i add a custom task pane in an Office VSTO add-in using C#?

Im using Visual Studio 2019 and Office 2016

1

1 Answers

1
votes

You should create a user control. Put some UI controls( in the solution I put a textbox and a button ) on that user controls as well as event handling. On the startup, ThisAddin adds the user control to the custom task pane.

Check out the sample solution I created on the following link PowerPoint Snap-In

… or use the following snippets. In ThisAddin.cs add two privates, one of type CustomTaskPane and the other of UserControl.

    // User control
    private UserControl _usr;
   // Custom task pane
    private Microsoft.Office.Tools.CustomTaskPane _myCustomTaskPane;

Create the user control. From the Project menu, choose 'Add User Control'. Add some UI elements to the user control ( e.g. textboxes, buttons, etc. ) Finally, in ThisAddin_Startup event handler that is created automatically for you by choosing Office VSTO project types, add following lines.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            //Create an instance of the user control
            _usr =new UserControl1();
            // Connect the user control and the custom task pane 
            _myCustomTaskPane = CustomTaskPanes.Add(_usr, "My Task Pane");
            _myCustomTaskPane.Visible = true;
        }

The result is shown in the image below enter image description here

More about Office VSTO on this link Office Development in Visual Studio