首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-03-13 
c# 开发excel工具栏c#增加工具栏,如何绑定点击工具栏按钮的事件.请高手解答下. 我的代码绑定的弹出窗体只

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 ();
  }

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

探讨

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

热点排行