【问题标题】:Outlook 2007 Addin access value in editBox on custom ribbonOutlook 2007 在自定义功能区上的编辑框中添加访问值
【发布时间】:2011-11-28 23:22:25
【问题描述】:

我正在使用 IRibbonExtensibility 与 VS2008 一起构建 Outlook 2007 插件。

我的简单功能区显示在 MailItem 上,并有一个编辑框和一个按钮控件。所需的功能是用户在编辑框中输入一个数字,然后单击按钮。然后将电子邮件信息保存到第三方系统中(使用在编辑框中输入的数字作为“主键”来控制位置等)

我在访问用户从按钮的回调函数输入到编辑框的值时卡住了。

我有关注标记

      <editBox
            id="FileNumber"
            maxLength="6"
            label="File No"
            />

      <button
            id="AddEmailTo"
            label="Save to"
            onAction ="AddEmailToButton_Action"
          />
    </group>
  </tab>

还有下面的回调

public void AddEmailToButton_Action (Microsoft.Office.Core.IRibbonControl p_Control) {

        //what do I need to add here to access the value in the editBox?
    }

谢谢 安德鲁

【问题讨论】:

    标签: c# visual-studio-2008 vsto outlook-addin


    【解决方案1】:

    您需要使用回调 onChange 将值存储在私有变量中

    在你的类中,声明一个私有变量来存储编辑框的值。 此变量将允许您获取文本框的值。

    private string FileNumberText = "initial value";
    

    要初始化默认值,请使用 getText 回调

    public string onGetText(IRibbonControl control) 
    {   
    switch (control.Id)
    {
        case "FileNumber":                      
            return FileNumberText ; 
        case "editBox02":
            return "...";
        default:
            return "";
    }               
    }
    

    记录editbox的变化(将editbox的值传给store变量)

            // Recupere le contenu du controle editBox dans la variable Cible
            public void  RecupDonnee(IRibbonControl control, String Text)
            {
                switch (control.Id)
                {
                    case "FileNumber":                      
                        FileNumberText = Text.Trim() ;  
                        break;
                    case "editBox02":
                        Screen2 = Text.Trim() ; 
                        break;
                }       
            }
    

    在您的功能区 XAML 中

    <editBox 
     id="FileNumber"
     maxLength="6"
     label="File No"                 
     getText="onGetText"
     onChange="RecupDonnee"
     screentip="Tip" 
    />
    

    【讨论】:

      猜你喜欢
      • 2011-07-25
      • 1970-01-01
      • 2012-05-07
      • 2014-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-07
      • 1970-01-01
      相关资源
      最近更新 更多