1
votes

I am building a Outlook 2007 Addin using with VS2008 using IRibbonExtensibility.

My simple ribbon displays on a MailItem and has a editBox and a button control. Required functionality is that the user enters a number in the editBox, then clicks the button. The email message is then saved into a third party system (using the number entered in the editBox as a “primary key” to control location etc)

I am stuck at the point of accessing the value the user has entered into the editBox from the callback function of the button.

I have the follow markup

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

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

And the following callback

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

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

Thanks andrew

1

1 Answers

3
votes

You need to store the value in a private variable with the callback onChange

In your class, declare a private variable to store the value of the editbox. This variable will allow you to get the value of a textbox.

private string FileNumberText = "initial value";

To initialise a defaut value, use getText callback

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

To record the change of editbox (pass the editbox value to the store variable)

        // 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;
            }       
        }

In your ribbon XAML

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