如何将function区button连接到Excel加载项中定义的function?

我正在使用MSVS 2013创build一个C#MS Excel加载项。 在以前的插件范例中,function区类devise器直接连接一个function区button单击事件以在Add-In应用程序类中运行 – 现在,function区function在function区类本身中定义。 从单独的function区控件类访问ThisAddIn类中定义的函数的最佳方法是什么?

这是一个简单的方法来做到这一点:

private void butRefreshSelectedWorksheets_Click(object sender, RibbonControlEventArgs e) { try { Globals.ThisAddIn.RefreshWorksheetListings(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error [butRefreshSelectedWorksheets_Click]: " + ex); } } 

使用Globals.ThisAddIn ….语法从function区内访问应用程序function。