Resizing vertically FlowLayoutPanel on Paint Event Handler?? C#
<p>I am creating a Office 2010 Add In which should behave like Toolbar available in Word 2003.
I should be able to resize Custom Task Pane when it is in floating Mode.
In Word 2003 we can use CommandBar class to accomplish this functionality but not in Word 2010.</p>

<p>I have created a add in for Word 2010 in which I have a Custom Task Pane which contains controls in following hierarchy.</p>

<p>CustomTaskPane
        UserControl
                FlowLayoutPanel 
                        ToolStrip
                                ToolStripButton</p>

<p>I wrote a Paint Event of Flow Layout Panel.
    flow.Paint +=new PaintEventHandler(flow_Resize);</p>

<pre><code> public void flow_Resize(object sender, PaintEventArgs e)
           {
               FlowLayoutPanel flow = sender as FlowLayoutPanel;
               var item = listCtpMgr.FirstOrDefault(o =&gt; o.flp.Name == flow.Name);
               if (item == null)
                   return;
               addedCTP = (Microsoft.Office.Tools.CustomTaskPane)item.ctp;
               if (addedCTP == null)
                   return;
               ToolStrip _toolstrip = (ToolStrip)flow.Controls[0];
               int MaxButtonWidthforThisToolbar = 0;
               foreach (ToolStripItem toolStripItem in _toolstrip.Items)
               {
                   if ((toolStripItem.Width) &gt; MaxButtonWidthforThisToolbar)
                   {
                       MaxButtonWidthforThisToolbar = (toolStripItem.Width);
                   }
               }
               MaxButtonWidthforThisToolbar += 10;
               if (addedCTP.DockPosition == MsoCTPDockPosition.msoCTPDockPositionLeft || addedCTP.DockPosition ==
   MsoCTPDockPosition.msoCTPDockPositionRight)
               {
                   if (addedCTP.Width &lt; MaxButtonWidthforThisToolbar)
                       addedCTP.Width = MaxButtonWidthforThisToolbar;
               }
               else if (addedCTP.DockPosition == MsoCTPDockPosition.msoCTPDockPositionTop || addedCTP.DockPosition ==
   MsoCTPDockPosition.msoCTPDockPositionBottom)
               {
                   addedCTP.Height = 50;
               }
               else
               {
                   addedCTP.Width = _toolstrip.Width + 27;
                   addedCTP.Height = _toolstrip.Height + 57;
               }

           }
</code></pre>

<p>I am able to resize the Custom Task Pane from left and right side but not from Top or Bottom when it is Floating. Also it is flickering when I am resizing it.Please help.</p>
