读书人

c# 开发excel工具栏解决思路

发布时间: 2012-03-13 11:21:12 作者: rapoo

c# 开发excel工具栏
c#增加工具栏,如何绑定点击工具栏按钮的事件.请高手解答下. 我的代码绑定的弹出窗体只能弹出一次.
MsExcel.Application excelapp = (MsExcel.Application)app;
CommandBar commandbar = excelapp.Application.CommandBars.Add("c# tool", MsoBarPosition.msoBarTop, false, true);
commandbar.Visible = true;
CommandBarButton _btn = (CommandBarButton)commandbar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true);
_btn.Caption = "caption";
_btn.Tag = "name";
_btn.Style = MsoButtonStyle.msoButtonCaption;
_btn.TooltipText = "caption";
_btn.Click += btnToolbarButton_Click;


protected void btnToolbarButton_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
Form aa = new Form1();
aa.Show ();
}

[解决办法]
按钮的变量 放 到 全局 上去!
[解决办法]

探讨

按钮的变量 放 到 全局 上去!

读书人网 >C#

热点推荐