none
Ribbon ToggleButton Click event is getting fired automatically RRS feed

  • Question

  • Hi,

    I am working on a Visual Studio 2012 Excel Add-In project in which I am using the Designer to create a custom Ribbon functionality. One of the controls in the Ribbon tab is a togglebutton which I am using as an alternative to radiobutton which   unfortunately is not provided in the add-in toolbox.

    I have published the Excel Add-In project using Load-on Demand setting (LoadBehavior 10(16) in registry). 

    My problem is when I launch Excel 2010, the togglebutton's click event gets fired automatically.  I have not even clicked on the Add-in tab at all. Merely launching excel 2010 from start menu is firing the event.

    Is there a way to prevent this unwanted behaviour?

    Interestingly, if the LoadBehavior setting in registry is  changed to 9 from 16 the issue is gone.

    Thanks

    Chaitak

    Saturday, October 11, 2014 11:50 AM

Answers

  • Hello Chaitak,

    > In the Ribbon1_Load method I am setting the togglebutton.checked property.

    It looks like that is the cause of the issue. Try to comment that line of code and see the results.

    Saturday, October 11, 2014 4:13 PM

All replies

  • Hello Chaitak,

    What Ribbon XML markup do you use in the add-in?

    Do you set any Ribbon UI related properties in the Load event handler?

    Are you able to reproduce the issue with a newly created empty add-in project?

    Saturday, October 11, 2014 12:44 PM
  • Hi Eugene,

    I am using the Ribbon Designer to design the Ribbon. I dont have any knowledge about RibbonXML.

    In the Ribbon1_Load method I am setting the togglebutton.checked property. I am also populating couple of combo boxes and few other things.

    I have not tried to reproduce the issue with a newly created empty add-in project but it looks like a very good idea which I will try.

    Saturday, October 11, 2014 3:08 PM
  • Hello Chaitak,

    > In the Ribbon1_Load method I am setting the togglebutton.checked property.

    It looks like that is the cause of the issue. Try to comment that line of code and see the results.

    Saturday, October 11, 2014 4:13 PM
  • Hi Eugene,

    Your suggestion solved the issue. Thank a lot for your help. You made my day..

    Looks like its a bug in the framework.

    If I build the solution with "Load On Demand" setting (LoadBehavior 10(16)), and with togglebutton.checked property set to true (either in designer properties window or in ribbon_load method), then togglebutton_click event is automatically fired. I think this is an unwanted/erroneous/buggy behavior and should be reported to Microsoft. This behavior is not observed if I use a checkbox instead of togglebutton.

    Regards

    Chaitak

    Sunday, October 12, 2014 3:14 PM
  • I just created a test excel-addin project and found that this auto-click-event ( with LoadOnDemand 10(16) setting) happens not only for togglebutton but also for other controls as well like check-box. Now I am worried as to how to prevent this auto-click event from happening because I need to set the checked property to true on ribbon_load but cannot do so without the above-mentioned consequence.

    On the other hand, if chose Load at startup option, the auto-click does not happen:

    Here is my code:

    namespace ExcelAddIn1
    {
        public partial class Ribbon1
        {
            private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
            {                   
            }
             private void toggleButton1_Click(object sender, RibbonControlEventArgs e)
            {
                toggleButton1.Label = "inside";
            }
        }
    }

    Tuesday, October 14, 2014 5:59 PM
  • the togglebutton.checked property should be set to true either in the designer properties or on ribbon_load for this behavior to occur.
    Wednesday, October 15, 2014 3:37 AM