如何将功能区按钮连接到一个Excel加载项中定义的函数? [英] How to connect a ribbon button to a function defined in an Excel add-in?

查看:484
本文介绍了如何将功能区按钮连接到一个Excel加载项中定义的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MSVS 2013创建一个C#MS Excel插件。在以前的外接范式,色带类设计器直接连接功能区按钮单击事件中的附加应用程序级的功能 - 现在色带功能在功能区类中定义,本身。什么是访问来自独立的色带控制类ThisAddIn类中定义的函数的最佳方式是什么?

I'm using MSVS 2013 to create a C# MS Excel Add-In. In previous add-in paradigms, the ribbon class designer directly connected a ribbon button click event to function in the Add-In application class - now the ribbon functions are defined in the ribbon class, itself. What is the best way to access a function defined in the ThisAddIn class from the separate ribbon control class?

推荐答案

这是一个简单的这样做的方法:

This is a simple method for doing this:

    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 ....语法从功能区中访问应用程序的功能。

Use the Globals.ThisAddIn.... syntax to access app functions from within the ribbon.

这篇关于如何将功能区按钮连接到一个Excel加载项中定义的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆