2

I'm using Visual Studio 2010 and Word 2010

I've created one Winform addin in Word following this guide Create addin using VSTO in MS Word

Now I want to dock this addin to word panel. I heard that I can do that by custom task pane, I tried but can't figure how.

Is there anyone know how to do this ?

Thank you very much :) I get the pane but can't add winform into it. Finally I have to put all my winform controls into usercontrol and now it works.

2 Answers 2

3

You should first create a User Control (you can do that using the designer), let's name it CustomUserControl, then add the following:

private CustomUserControl myUserControl;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;

Now, in your task pane class or AddIn_Startup function, add the following:

myUserControl = new CustomUserControl();
myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(myUserControl, "TaskPane Title");

You can control the visibility of the task pane by changing the Visible property: myCustomTaskPane.Visible = true;

Note that in Word when you create such custom task pane, it will be associated with the active document. Depends on what you're trying to do, you should consider creating for each document its own instance. For more information refer to here: Managing Custom Task Panes in Multiple Application Windows

Sign up to request clarification or add additional context in comments.

2 Comments

for me this.CustomTaskPanes is null. why?
i am creating document level add-in.
0

I don't know your code. but here i paste my code. try this.

 private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        //User Control
        uctrl_TextControl sampleControl = new uctrl_TextControl();
        Microsoft.Office.Tools.CustomTaskPane _customeTaskPane = this.CustomTaskPanes.Add(sampleControl, "Sample");
        _customeTaskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;
        _customeTaskPane.Visible = true;
        _customeTaskPane.Width = 400;
    }

2 Comments

Thanks for your quick answer, dock pane did appear, how can I add my winform into it ?
first line i instantiate the winform user control. add the object to custome task pane.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.