如何从RibbonControl按钮的Click事件访问ThisAddin中的方法贴花? [英] How to access method decalre in ThisAddin from RibbonControl Button Click Event?

查看:172
本文介绍了如何从RibbonControl按钮的Click事件访问ThisAddin中的方法贴花?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Outlook开发了一个自定义加载项.

而且我还在Outlook功能区栏上放了一些自定义按钮.

现在我的问题是,我想通过自定义按钮的(位于RibbonBar上)Click事件调用在ThisAddin类(默认情况下由Addin创建)上声明的一个方法.


为此,我现在使用ThisAddin类的新实例来调用该方法,但是我会创建一些问题.所以我想知道任何其他方法,而无需创建ThisAddin类的新实例,可以从Button Click事件中调用我的方法.

还是可以通过按钮单击"事件调用发送项目"事件.


我现在正在使用的就是这样....

I have develop one Custom addin for Outlook.

and i have put some custome button on Outlook Ribbon bar also.

now what is my problem is, i want to call one method declared on ThisAddin class (which is by default created by Addin), from by custom button''s(which is placed on RibbonBar) Click event.


for this right now i am using a new instance of ThisAddin class to call that method, but i will creating some issues. so i want to know any other method with out creating new instance of ThisAddin class can i call my method from Button Click event.

or can i call Send Item event from by Button Click event.


what i am using right now is like this....

private void btnProtect_Click(object sender, RibbonControlEventArgs e)
{
    using (ThisAddIn _addIn = new ThisAddIn())
    {
        //Here what i do is Create one new Instance of ThisAddin Class
        //And Access it's ItemSend() method throught it.
        _addIn.ItemSend();
    
    }
}




我想要的是不创建任何新实例,而我想从功能区中调用该方法->按钮->点击事件



我想从功能区控制按钮单击事件触发Application.ItemSend事件.


请提供您的宝贵建议.




What i want is with out createing any new instance i want to call that method from my ribbon -> button -> click event

OR

I want to Fire a Application.ItemSend event from Ribbon Control Button Click Event.


please provide your valuable suggestions.

推荐答案

听起来像您想要使用静态类或静态成员函数的声音:

http://msdn.microsoft.com/en-us/library/79b3xss3 (v = vs.80).aspx [
Sounds like you want to use a static class or static member function:

http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx[^]


最后,我找到了解决方案.
我为此要做的是访问邮件项目并使用邮件项目send()方法,这样它将自动触发Application_Item Send事件.

这样.

Finally i found the solution for this.
what i do for this is to access the mail item and use mail items send() method so it will fire Application_Item Send event automatically.

like this.

private void btnProtect_Click(object sender, RibbonControlEventArgs e)
{
    //FormFactory is User Defined Class to store local Variables
    //Here i already store my MailItem Object
    FormFactory.Instance.OutlookMailItem.Send();
}


这篇关于如何从RibbonControl按钮的Click事件访问ThisAddin中的方法贴花?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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