none
ribbon.InvalidateControl() does not work unless the Inspector is "Activated" again. RRS feed

  • Question

  • I am using Ribbon XML and VS 2010 to build some custom button controls to Outlook 2010, but having some problem refreshing the state of the buttons.

    I created 2 buttons for idMso="TabReadMessage" (Reading email window/inspector).

    Ribbon XML code for the buttons:

    <tab idMso="TabReadMessage">
    	<group id="MyGroup" label="My Label">
    		 <splitButton id="MySplitButton" keytip="QS" size="large">
    			  <button id="SplitButton1" onAction="SplitButton1_Click" label="SplitButton 1" />
    			  <menu id="SplitButton_mnu" keytip="QS">
    					<button id="Button1" onAction="Button1_Click" label="Button 1" />
    					<button id="Button2" onAction="Button2_Click" label="Button 2"/>
    			  </menu>
    		 </splitButton>
    		 <toggleButton id="MyToggleButton" onAction="MyToggleButton_Click" size="large" label="Toggle Button" getEnabled="GetEnabledToggleButton" />
    	</group>
    </tab>

    Split button click callback:

    Public Sub SplitButton1_Click(ByVal control As IRibbonControl)
    	ribbon.InvalidateControl("MyToggleButton")
    End Sub

    Toggle button getEnabled callback event:

    Public Function GetEnabledToggleButton(ByVal control As IRibbonControl) As Boolean
    	Return False
    End Function

    What I want to achieve is that after I click on the SplitButton, the ToggleButton will be disabled, I am using ribbon.InvalidateControl("MyToggleButton") to invalidate the control and this should fire the getEnabled callback event for the ToggleButton, but it didn't.  But if I click away from the inspector window and click in again to the inspector window, the state will change and work.  I thought InvalidateControl() will change the state of the control immediately?

    Please help, thanks.



    • Edited by Ah Lun Wednesday, October 24, 2012 4:16 AM
    Wednesday, October 24, 2012 4:13 AM

Answers

  • I create a subroutine in the Addin class, in this subroutine I invalidate the MyToggleButton control.

    The SplitButton1_Click() event will call the subroutine, thus will invalidate the MyToggleButton control, this work, but not sure whether there is a better/recommended way to do this.

    • Marked as answer by Ah Lun Monday, October 29, 2012 10:02 AM
    Thursday, October 25, 2012 1:28 AM

All replies

  • I create a subroutine in the Addin class, in this subroutine I invalidate the MyToggleButton control.

    The SplitButton1_Click() event will call the subroutine, thus will invalidate the MyToggleButton control, this work, but not sure whether there is a better/recommended way to do this.

    • Marked as answer by Ah Lun Monday, October 29, 2012 10:02 AM
    Thursday, October 25, 2012 1:28 AM
  • Hi Ah Lun,

    I am glad to hear that you have got it working to resolve this issue.

    Thank you for sharing the solution in the forum. It will beneficial for other community members who have the similar problem.

    Best Regards,


    Leo_Gao [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, October 30, 2012 1:39 AM
    Moderator