有没有办法控制包含加载项的左侧任务窗格的宽度?
我有一个使用 VS2010 VSTO 库内置的 excel 2007 插件。 当我创建加载项的新对象时,我还使用以下代码创建一个 Excel 左侧任务窗格:
Microsoft.Office.Tools.CustomTaskPane taskPaneAddIn;
MyAddIn addIn;
addIn = new MyAddIn(this.Application);
taskPaneAddIn = this.CustomTaskPanes.Add(addIn, "My AddIn");
taskPaneAddIn.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft;
taskPaneAddIn.Width = addIn.Size.Width + 5;
加载项是一个 Windows 用户控件,它有自己的尺寸。
上面的代码似乎不起作用,因为 Excel 上的 taskPaneAddIn
宽度始终是固定的。用户始终必须手动展开任务窗格才能看到控件的整个宽度。
有没有可编程的方法来设置任务窗格宽度?
I have an excel 2007 Add-in built with VS2010 VSTO library.
when i create a new object of the add-in, i also create an excel left task pane, using the following code:
Microsoft.Office.Tools.CustomTaskPane taskPaneAddIn;
MyAddIn addIn;
addIn = new MyAddIn(this.Application);
taskPaneAddIn = this.CustomTaskPanes.Add(addIn, "My AddIn");
taskPaneAddIn.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft;
taskPaneAddIn.Width = addIn.Size.Width + 5;
The addIn is a windows user control which has its own dimensions.
The code above seems not to work as the taskPaneAddIn
width is always fixed on the excel. the user always has to manually expand the task pane to see the entire width of the control.
Is there any programmable way to set the task pane width?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题的根源在于,当您将控件添加到 CustomTaskPanes 时,其宽度设置为零(我认为这与控件停靠的事实有关)。要解决您的问题,您可以执行以下操作,并在添加控件之前检索控件的宽度:
I think the source of your problem is that when you add the control to the CustomTaskPanes, its Width gets set to zero (I think it has to do with the fact that the control gets docked). To address your problem, you can do the following, and retrieve the width of your control before it is added: