![]() |
Adding Dynamic Buttons to the RibbonUI
I am having trouble creating new controls on the Ribbon at Runtime.
Given the following sample scenario: When a user opens a certain task - I want to replace the ribbon and add a set of buttons based on that specific task. The problem is the number of buttons being added is not fixed. So Task A might have 3 buttons and Task B might have 5 buttons. Since the number of buttons isn't fixed, I don't see a way to define the buttons ahead of time in the RibbonX definition and use callbacks to update the content of each button. So, I also looked at using the GetCustomUI call to change the XML that is loaded, but this only called the first time Ribbon loads - even if I call Invalidate, so it works for the first task that opens, but how do I update it for the next task that opens? Does anyone have a similar problem or a solution to adding the buttons to the Ribbon in the C# code at runtime? |
Adding Dynamic Buttons to the RibbonUI
You certainly can define the maximum number of buttons in your XML with
getVisible and getEnabled callbacks and set the visibility and enabled status of each button in the callbacks. I do that in some of my addins that support the ribbon. You can also use the dynamicMenu control, you can read about that in the information about the ribbon on the MSDN site. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "kapkema" wrote in message ... I am having trouble creating new controls on the Ribbon at Runtime. Given the following sample scenario: When a user opens a certain task - I want to replace the ribbon and add a set of buttons based on that specific task. The problem is the number of buttons being added is not fixed. So Task A might have 3 buttons and Task B might have 5 buttons. Since the number of buttons isn't fixed, I don't see a way to define the buttons ahead of time in the RibbonX definition and use callbacks to update the content of each button. So, I also looked at using the GetCustomUI call to change the XML that is loaded, but this only called the first time Ribbon loads - even if I call Invalidate, so it works for the first task that opens, but how do I update it for the next task that opens? Does anyone have a similar problem or a solution to adding the buttons to the Ribbon in the C# code at runtime? |
Adding Dynamic Buttons to the RibbonUI
Hi Ken -
I am thinking that creating an excess of buttons and hiding them might be the way to go. However, in my case, this is difficult because there is no maximum number constraint on the system the AddIn will be based on. I will have to look into this option a little more. I have also looked into the dynamic menu option some as well. I was wondering if there is a way to make the dynamic menu appear as a set of buttons on the Ribbon, instead of in a context menu or a split button menu. Is this possible? If so, that is definitely the way to go. Thanks again for the help! Marc Kapke "Ken Slovak - [MVP - Outlook]" wrote: You certainly can define the maximum number of buttons in your XML with getVisible and getEnabled callbacks and set the visibility and enabled status of each button in the callbacks. I do that in some of my addins that support the ribbon. You can also use the dynamicMenu control, you can read about that in the information about the ribbon on the MSDN site. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "kapkema" wrote in message ... I am having trouble creating new controls on the Ribbon at Runtime. Given the following sample scenario: When a user opens a certain task - I want to replace the ribbon and add a set of buttons based on that specific task. The problem is the number of buttons being added is not fixed. So Task A might have 3 buttons and Task B might have 5 buttons. Since the number of buttons isn't fixed, I don't see a way to define the buttons ahead of time in the RibbonX definition and use callbacks to update the content of each button. So, I also looked at using the GetCustomUI call to change the XML that is loaded, but this only called the first time Ribbon loads - even if I call Invalidate, so it works for the first task that opens, but how do I update it for the next task that opens? Does anyone have a similar problem or a solution to adding the buttons to the Ribbon in the C# code at runtime? |
Adding Dynamic Buttons to the RibbonUI
No, it's not possible. A dynamicMenu will always appear the same way.
-- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "kapkema" wrote in message ... Hi Ken - I am thinking that creating an excess of buttons and hiding them might be the way to go. However, in my case, this is difficult because there is no maximum number constraint on the system the AddIn will be based on. I will have to look into this option a little more. I have also looked into the dynamic menu option some as well. I was wondering if there is a way to make the dynamic menu appear as a set of buttons on the Ribbon, instead of in a context menu or a split button menu. Is this possible? If so, that is definitely the way to go. Thanks again for the help! Marc Kapke |
All times are GMT +1. The time now is 12:31 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com