2

I'm writing an outlook add-in and I'm looking for a way to make a panel docked on the right of my screen collapsible. At the moment the panel is either displayed or removed. You can also scale it but that's not what I'm looking for. I already tried adding 2 buttons which change the width of my panel onclick but the result is that my panel can't get smaller than about 60px in width and the title is still there. Here is the code I use to add my pane:

 Microsoft.Office.Tools.CustomTaskPane ctp;
 private HistoryPane ctrl;
 string title = "Task History";
 ctrl = new HistoryPane(mailItem);
 ctp = Globals.ThisAddIn.CustomTaskPanes.Add(ctrl, title);
 ctp.Visible = true;
 ctp.Width = 460;
 ctp.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;

Any help to either remove the title, make the panel thinner (about 25px), make it collapsible or all of them would be much appreciated.

Toon Casteele
  • 2,479
  • 15
  • 25

1 Answers1

2

here is solution below:

1 - Create a public method in your user control like below:

    private Microsoft.Office.Tools.CustomTaskPane _ctp;
    public void SetControl(ref Microsoft.Office.Tools.CustomTaskPane ctp)
    {
        _ctp = ctp;
    }

2 - Add any button to Expend and Minimize in your User Control and put below codes on Minimize button on click event:

    private void btnMinimize_Click(object sender, EventArgs e)
    {
        _ctp.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionTop;
        _ctp.Height = 50;
    }

3 - After your code above use bold line code below:

Microsoft.Office.Tools.CustomTaskPane ctp;
private HistoryPane ctrl;
string title = "Task History";
ctrl = new HistoryPane(mailItem);
ctp = Globals.ThisAddIn.CustomTaskPanes.Add(ctrl, title);
ctp.Visible = true;
ctp.Width = 460;
ctp.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;

ctrl.SetControl(ref ctp);

Hope this will work.

SysDragon
  • 9,692
  • 15
  • 60
  • 89
Rup
  • 21
  • 3
  • This just provides me with a different way to add the panel but not a way to make the width go to 25px or lower. There is still a minimal width – Toon Casteele Apr 08 '13 at 14:42