none
Can we force user to select only one checkbox out of multiple checkboxes in the menu control of VSTO Ribbon XML? RRS feed

  • Question

  • I am using VSTO 2013 for office 2010 I need to implement the Radio buttons functionality. But VSTO does not have radio button control. In my Ribbon XML I have a menu tag (control) that has three checkboxes. I want the user to be able to check only one of those checkboxes. How can I achieve this? Please note that in VSTO, you can access the state of only currently selected control; so if one checkbox is selected I cannot uncheck the other checkboxes programmatically. Thanks..Nam
    Sunday, December 14, 2014 8:32 PM

Answers

  • Hi namwam,

    Based on the description, you want to use radio buttons on the ribbon. As far as I konw, the radio button is not supported at present.

    As a workaround, we can use dropdown. Also if you want to use check box to instead of radio button, we can create a ribbon with Visual design and we can uncheck the other checkbox when we click the checkbox. Here is the code for your referece:

         private void checkBox1_Click(object sender, RibbonControlEventArgs e)
            {
                UnCheckAll(e.Control.Id);
            }
    
            private void UnCheckAll(string id)
            {
                if (checkBox1.Id != id)
                    checkBox1.Checked = false;
                if (checkBox2.Id != id)
                    checkBox2.Checked = false;
            }
    
     

    Also if you want to the ribbon support radio button, I suggest that you submit the feedback from link below:
    Submit Feedback - Office - Microsoft

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 15, 2014 9:59 AM
    Moderator
  • I'd suggest using callbacks for invalidating (see IRibbonUI.Ivalidate for more information) the state of all checkboxes. For example, if a user clicked a particular checkbox you may set a local variable pointing to the value set. Then in the Ribbon callbacks we can check the current state and refresh all controls leaving only one checked.

    You can read more about the Ribbon UI (aka Fluent UI) in the following series of articles:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    Monday, December 15, 2014 11:34 AM

All replies

  • Hi namwam,

    Based on the description, you want to use radio buttons on the ribbon. As far as I konw, the radio button is not supported at present.

    As a workaround, we can use dropdown. Also if you want to use check box to instead of radio button, we can create a ribbon with Visual design and we can uncheck the other checkbox when we click the checkbox. Here is the code for your referece:

         private void checkBox1_Click(object sender, RibbonControlEventArgs e)
            {
                UnCheckAll(e.Control.Id);
            }
    
            private void UnCheckAll(string id)
            {
                if (checkBox1.Id != id)
                    checkBox1.Checked = false;
                if (checkBox2.Id != id)
                    checkBox2.Checked = false;
            }
    
     

    Also if you want to the ribbon support radio button, I suggest that you submit the feedback from link below:
    Submit Feedback - Office - Microsoft

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 15, 2014 9:59 AM
    Moderator
  • I'd suggest using callbacks for invalidating (see IRibbonUI.Ivalidate for more information) the state of all checkboxes. For example, if a user clicked a particular checkbox you may set a local variable pointing to the value set. Then in the Ribbon callbacks we can check the current state and refresh all controls leaving only one checked.

    You can read more about the Ribbon UI (aka Fluent UI) in the following series of articles:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    Monday, December 15, 2014 11:34 AM