Enable/Disable a ribbon control based on a condition RRS feed

  • Question

  • Hi

     I have created a ribbon dynamically from xml file that is in server.( Not the Ribbon.xml). Now the ribbon is working  fine. The Problem is on certain condition i want to disable a dynamic button "btnSubmit".


    I googled and find many solutions but any of them are not working in my scenarios, bcoz of  i am not using Ribbon.xml file to get the functionality of "getEnabled" functionalities are not available to me. ( i am  working on custom xml file to add controls to the ribbon)


    Plz help me in getting this done.



    Tuesday, April 26, 2011 7:58 AM

All replies

  • Are you building the xml-string for the ribbon dynamically? If so u could easily just do something like this:

    <button id="btnSomeButton" getEnabled="Btn_GetEnabled" />

    and in u'r code:

    public bool Btn_GetEnabled(IRibbonControl control)
       //Do something here and return if button should be enabled or not, that is - true or false
       return true;

    Andreas M.
    Tuesday, April 26, 2011 8:55 AM
  • Hi Prasad

    You're a bit vague about how you're actually creating and managing the Ribbon in your application...

    Is this a VSTO add-in or document-level solution? If yes, did you use the Ribbon Designer? Which Office application and version?

    If you did not use the Ribbon Designer, and you say you aren't using Ribbon XML, please provide more information on how you "created a ribbon dynamically" and bound it to your solution (whatever kind it is). We can't possibly provide support if we don't know what you're doing.

    Cindy Meister, VSTO/Word MVP
    Tuesday, April 26, 2011 4:38 PM