none
How to clear a drop down list selection in custom ribbon ? RRS feed

  • Question

  • I have this problem;

    I've created a custom ribbon with drop down list:

                        <dropDown id= "ListaRaporty" label= "Rodzaj raportu" onAction= "raport_rodzaj_action">
                            <item id= "okresowy" label= "Okresowy"/>
                            <item id= "końcowy" label= "Końcowy"/>
                        </dropDown>

    The problems is when I choose ie. "Okresowy" it stays as a selection after the code from raport_rodzaj_action is finished. I wish to clear drop down list selection somehow on certain action.

    Any ideas how to do this ?

    Thursday, April 4, 2013 12:59 PM

Answers

  • Hi rayjk

    Add the following call back:

    Sub CallbackDDGetSelectedItemID(control As IRibbonControl, _
                             ByRef itemID)
        
        ' Callback get the selected item for the the dropdown Control
        
        Select Case control.ID
            Case "myDropDown"
                itemID = ""
        End Select
    
    End Sub

    Then call: objRibbon.InvalidateControl ("myDropDown") in DropDown's OnAction event.

    '' Function for DropDown1 Ribbon
    Sub MyDropDownCallbackOnAction(control As IRibbonControl, _
                                 selectedId As String, _
                                 selectedIndex As Integer)
        ' Callback onAction
        Select Case control.ID
            Case "myDropDown"
                MsgBox selectedId & " " & selectedIndex
        End Select
        objRibbon.InvalidateControl ("myDropDown")
       
    End Sub

    The ribbon xml is here for your reference:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="fncRibbon">
        <ribbon startFromScratch="false"  >
            <tabs>
                <tab id="MyTab" label="My Tab">
                    <group id="MyGroup" label="My Group">
                        <labelControl id="myLabel1" label="Sample:" />
                        <labelControl id="myLabel2" label="DropDown" />
                        <dropDown id="myDropDown"
                                  showLabel="true"
                                  label="DropDown"
                                  onAction="MyDropDownCallbackOnAction"       getSelectedItemID="CallbackDDGetSelectedItemID">
                            <item id="itmDD1" label="one" />
                            <item id="itmDD2" label="two" />
                            <item id="itmDD3" label="three" />
                        </dropDown>
                     </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>

    Good day.


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by rayjk Monday, April 8, 2013 7:42 AM
    Friday, April 5, 2013 7:57 AM
    Moderator

All replies

  • Hi rayjk

    Add the following call back:

    Sub CallbackDDGetSelectedItemID(control As IRibbonControl, _
                             ByRef itemID)
        
        ' Callback get the selected item for the the dropdown Control
        
        Select Case control.ID
            Case "myDropDown"
                itemID = ""
        End Select
    
    End Sub

    Then call: objRibbon.InvalidateControl ("myDropDown") in DropDown's OnAction event.

    '' Function for DropDown1 Ribbon
    Sub MyDropDownCallbackOnAction(control As IRibbonControl, _
                                 selectedId As String, _
                                 selectedIndex As Integer)
        ' Callback onAction
        Select Case control.ID
            Case "myDropDown"
                MsgBox selectedId & " " & selectedIndex
        End Select
        objRibbon.InvalidateControl ("myDropDown")
       
    End Sub

    The ribbon xml is here for your reference:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="fncRibbon">
        <ribbon startFromScratch="false"  >
            <tabs>
                <tab id="MyTab" label="My Tab">
                    <group id="MyGroup" label="My Group">
                        <labelControl id="myLabel1" label="Sample:" />
                        <labelControl id="myLabel2" label="DropDown" />
                        <dropDown id="myDropDown"
                                  showLabel="true"
                                  label="DropDown"
                                  onAction="MyDropDownCallbackOnAction"       getSelectedItemID="CallbackDDGetSelectedItemID">
                            <item id="itmDD1" label="one" />
                            <item id="itmDD2" label="two" />
                            <item id="itmDD3" label="three" />
                        </dropDown>
                     </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>

    Good day.


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by rayjk Monday, April 8, 2013 7:42 AM
    Friday, April 5, 2013 7:57 AM
    Moderator
  • Thank You Yoyo - works fine :) !
    Monday, April 8, 2013 7:42 AM