Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Paint事件处理程序上调整垂直FlowLayoutPanel的大小??C#_C# - Fatal编程技术网

在Paint事件处理程序上调整垂直FlowLayoutPanel的大小??C#

在Paint事件处理程序上调整垂直FlowLayoutPanel的大小??C#,c#,C#,我正在创建一个Office 2010加载项,其行为应该类似于Word 2003中提供的工具栏。 当自定义任务窗格处于浮动模式时,我应该能够调整其大小。 在Word2003中,我们可以使用CommandBar类来完成此功能,但在Word2010中不能 我已经为Word 2010创建了一个外接程序,其中有一个自定义任务窗格,其中包含以下层次结构中的控件 自定义任务窗格 用户控制 流程布局面板 工具栏 ToolStripButton 我写了一个Flow Layout Panel的绘画事件。 flow.

我正在创建一个Office 2010加载项,其行为应该类似于Word 2003中提供的工具栏。 当自定义任务窗格处于浮动模式时,我应该能够调整其大小。 在Word2003中,我们可以使用CommandBar类来完成此功能,但在Word2010中不能

我已经为Word 2010创建了一个外接程序,其中有一个自定义任务窗格,其中包含以下层次结构中的控件

自定义任务窗格 用户控制 流程布局面板 工具栏 ToolStripButton

我写了一个Flow Layout Panel的绘画事件。 flow.Paint+=新的PaintEventHandler(flow\u Resize)

public void flow\u Resize(对象发送器,PaintEventArgs e)
{
FlowLayoutPanel flow=发送方作为FlowLayoutPanel;
var item=listCtpMgr.FirstOrDefault(o=>o.flp.Name==flow.Name);
如果(项==null)
返回;
addedCTP=(Microsoft.Office.Tools.CustomTaskPane)item.ctp;
if(addedCTP==null)
返回;
ToolStrip _ToolStrip=(ToolStrip)flow.Controls[0];
int MaxButtonWidthFortHistorolBar=0;
foreach(ToolStripItem ToolStripItem在_toolstrip.Items中)
{
if((toolStripItem.Width)>MaxButtonWidthFortHistorolBar)
{
MaxButtonWidthFortHistorolBar=(toolStripItem.Width);
}
}
MaxButtonWidthForHistorolBar+=10;
if(addedCTP.DockPosition==MsoCTPDockPosition.MsoCTPDockPosition left | | addedCTP.DockPosition==
msoctpodockPosition.msoctpodockPositionRight)
{
if(addedCTP.Width

当自定义任务窗格浮动时,我可以从左侧和右侧调整其大小,但不能从顶部或底部调整。当我调整它的大小时,它也会闪烁。请帮助。

我没有看到任何正在进行的绘画。尝试改用resize事件:
flow.resize+=neweventhandler(flow\u resize)
并将参数从PaintEventArgs更改为EventArgs。我已尝试调整事件大小。但是当CustomTaskPane的大小小于ToolStrip的大小时,它不能限制用户。此外,如果事件连续触发,则无法正确设置高度和宽度。我也尝试了SuspendLayout和ResumeLayout。但是没有帮助
 public void flow_Resize(object sender, PaintEventArgs e)
           {
               FlowLayoutPanel flow = sender as FlowLayoutPanel;
               var item = listCtpMgr.FirstOrDefault(o => 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) > MaxButtonWidthforThisToolbar)
                   {
                       MaxButtonWidthforThisToolbar = (toolStripItem.Width);
                   }
               }
               MaxButtonWidthforThisToolbar += 10;
               if (addedCTP.DockPosition == MsoCTPDockPosition.msoCTPDockPositionLeft || addedCTP.DockPosition ==
   MsoCTPDockPosition.msoCTPDockPositionRight)
               {
                   if (addedCTP.Width < 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;
               }

           }