Two different ADXRibbonMenu´s in ribbon will show the same controls

Add-in Express™ Support Service
That's what is more important than anything else

Two different ADXRibbonMenu´s in ribbon will show the same controls
 
Subscribe
dik




Posts: 6
Joined: 2012-08-29
Hi there,

i have two different ADXRibbonMenu´s in a Word ribbon.

both ADXRibbonMenu´s will be filled with different ADXRibbonButton´s in their own OnCreate-event via e.AddControl(button)

For example:


private void ribbonMenu1_OnCreate(object sender, ADXRibbonCreateMenuEventArgs e)
{
            int buttonIdCount = 1;


                    foreach (AddinExpress.MSO.ADXRibbonButton control in ribbonMenu1.Controls)
                    {
                        if (control.Id == "newButton" + buttonIdCount)
                        {
                            buttonIdCount++;
                        }
                    }

                    ADXRibbonButton newButton1 = new ADXRibbonButton()
                    {
                        Caption = "Test1",
                        Tag2 = item.FullName,

                        Id = "newButton" + buttonIdCount
                    };
					
                    e.AddControl(newButton1);
					
}

private void ribbonMenu2_OnCreate(object sender, ADXRibbonCreateMenuEventArgs e)
{
            int buttonIdCount = 1;


                    foreach (AddinExpress.MSO.ADXRibbonButton control in ribbonMenu2.Controls)
                    {
                        if (control.Id == "newButton" + buttonIdCount)
                        {
                            buttonIdCount++;
                        }
                    }

                    ADXRibbonButton newButton2 = new ADXRibbonButton()
                    {
                        Caption = "Test2",
                        Tag2 = item.FullName,

                        Id = "newButton" + buttonIdCount
                    };
					
                    e.AddControl(newButton2);
}


First i click ribbonMenu1 and it show´s me the button "Test1", after that i click ribbonMenu2 and it show´s me the button "Test2" AND the button from the first ADXRibbonMenu ribbonMenu1...
This error can be reproduced in both directions...

i´ve tested this also via ribbonMenu1.Controls.Add(newButton1) and ribbonMenu2.Controls.Add(newButton2) with the same error.


Is this maybe a bug or am I doing something wrong?
Posted 19 Jul, 2019 06:22:40 Top
Andrei Smolin


Add-in Express team


Posts: 16436
Joined: 2006-05-11
Hello dik,

dik writes:
ADXRibbonButton newButton1 = new ADXRibbonButton()


In this way, the add-in mo0dule won't know about the button. Use this line instead:

ADXRibbonButton newButton1 = new ADXRibbonButton(this.components)

Also, see code samples in section Creating Ribbon Controls at Run Time, see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jul, 2019 02:51:24 Top
Andrei Smolin


Add-in Express team


Posts: 16436
Joined: 2006-05-11
Another point. The buttons as well as all other custom Ribbon controls must have unique IDs.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jul, 2019 02:53:33 Top
dik




Posts: 6
Joined: 2012-08-29
Hello Andrei,

yout tip "ADXRibbonButton newButton1 = new ADXRibbonButton(this.components)" in combination with unique ID´s was the answer!

Thank you and have a nice day
Posted 22 Jul, 2019 04:06:47 Top
Andrei Smolin


Add-in Express team


Posts: 16436
Joined: 2006-05-11
Great!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jul, 2019 05:06:05 Top