mekafe mekafe - 8 months ago 47
C# Question

Loading form region dynamically in Outlook Add-In

I'm working on a Outlook Add-In.I put a new tab to my ribbon that includes a button inside it.On the other hand, I have a form region that has my controls.

I want to show my form region when the button has been clicked. How can i implement this?

Best Regards.


First of all you need to set up your click event inside a ribbon.xml. If you have an extra tab already showing you should already have a ribbon.xml.

My example of ribbon.xml with the button click event:

<?xml version="1.0" encoding="UTF-8"?>
        <contextMenu idMso="ContextMenuMailItem">
            <menu id="MailMenu" label="Ribbon Actions" image="Icon">
                <button id="NewFromEmail" label="New" onAction="NewFromEmail_Click" />

Notice I have added onAction="NewFromEmail_Click" to the button.

Then inside you main ribbon class you will need to create the click event method we just added to the button. Inside this method you can put your form.Show();. Then whenever you click that ribbon button that code will fire.

public void NewFromEmail_Click(Office.IRibbonControl control)

If you have any questions about what I have just said please comment, I am not the greatest at explaining things.