locked
Checkbox in Ribbon automatically uncheck when custom task pane closed RRS feed

  • Question

  • Hi all,
    I've just created a add-in in which a ribbon that has a checkbox.. When checkbox is checked, a custom taskpane displays and vice versa

    This is ribbon.xml
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad">
      <ribbon>
        <tabs>
            <tab idMso="TabAddIns" label="Utilities">
                <group id="idUtilities"
                       label="Tools">              
                    <checkBox id="SRSGenerator"                           
                                  label="SRS Generator"
                                  onAction="OnSRSGenerator"
                                  />
                </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>

    And this is code in Ribbon.cs
    public void OnSRSGenerator(Office.IRibbonControl control, bool isChecked){
           Globals.ThisAddIn.CustomTaskPanes[0].Visible = isChecked;
    }

    But I don't know how to make Checkbox in Ribbon automatically uncheck when custom task pane closed (eg, user cllick x button in custom taskpane).

    Pls tell me the solution.

    Thanks very much
    Saturday, July 7, 2007 5:26 PM

Answers

  • Hi all, I found the solution.

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad">
      <ribbon>
        <tabs>
            <tab idMso="TabAddIns" label="Utilities">
                <group id="idUtilities"
                       label="Tools">              
                    <checkBox id="SRSGenerator"                           
                                  label="SRS Generator"
                                  onAction="OnSRSGenerator"
                                  onPressed="OnSRSGeneratorPressed"
                                  />
                </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>

    And this is code in Ribbon.cs
    public
    bool OnSRSGeneratorPressed(Office.IRibbonControl control){
           return Globals.ThisAddIn.CustomTaskPanes[0].Visible;
    }

    In the ThisAddIn class, the code to process visible_Changed of the custom taskpane must call
    ribbon.Invalidate("SRSGenerator")

    I found this solution when I was surfing this forum Smile
    Wednesday, July 11, 2007 2:14 PM

All replies

  • Hi all, I found the solution.

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad">
      <ribbon>
        <tabs>
            <tab idMso="TabAddIns" label="Utilities">
                <group id="idUtilities"
                       label="Tools">              
                    <checkBox id="SRSGenerator"                           
                                  label="SRS Generator"
                                  onAction="OnSRSGenerator"
                                  onPressed="OnSRSGeneratorPressed"
                                  />
                </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>

    And this is code in Ribbon.cs
    public
    bool OnSRSGeneratorPressed(Office.IRibbonControl control){
           return Globals.ThisAddIn.CustomTaskPanes[0].Visible;
    }

    In the ThisAddIn class, the code to process visible_Changed of the custom taskpane must call
    ribbon.Invalidate("SRSGenerator")

    I found this solution when I was surfing this forum Smile
    Wednesday, July 11, 2007 2:14 PM

  • It helps me out of the problem, It is good for reference.
    Saturday, January 29, 2011 12:07 AM