Tobias B?hm
Posts: 73
Joined: 2009-07-06
|
I try to dynamically add ADXRibbonButtons to an ADXRibbonGroup. I do this from inside the OnRibbonBeforeCre ate event. The creation works find but after the OnRibbonBeforeCre ate event the OnError event gets fired with following exception:
"Object reference not set to an instance of an object.
at AddinExpress.MSO.ADXRibbonButton.GetAttributes()
at AddinExpress.MSO.ADXRibbonCustomControl.AddinExpress.MSO.IADXRibbonComponent.get_Attributes()
at AddinExpress.MSO.ADXAddinModule.ProcessChildren(XmlTextWriter xmlData, IADXRibbonComponent ribbonElement, String ribbonID)
at AddinExpress.MSO.ADXAddinModule.ProcessChildren(XmlTextWriter xmlData, IADXRibbonComponent ribbonElement, String ribbonID)
at AddinExpress.MSO.ADXAddinModule.ProcessChildren(XmlTextWriter xmlData, IADXRibbonComponent ribbonElement, String ribbonID)
at AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IRibbonExtensibility.GetCustomUI(String RibbonID)"
I use following code inside a loop to add the buttons
AddinExpress.MSO.ADXRibbonButton r = new AddinExpress.MSO.ADXRibbonButton
{
Id = "ColorButtonID_" + c.ToString(),
Tag = c.ToArgb(),
Caption = string.Empty,
ScreenTip = c.ToString(),
ImageList = imageList,
Image = index++,
Enabled = true
};
adxRibbonGroup.Controls.Add(r);
Thanks in advance,
Tobias |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hi Tobias,
Try using a non-empty string in the Caption property.
Andrei Smolin
Add-in Express Team Leader |
|
Tobias B?hm
Posts: 73
Joined: 2009-07-06
|
Sorry, that didn't work either.
Do you have an example about how to add buttons at run-time?
Tobias |
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Tobias.
Do you pass the 'this.components' field as a parameter to the ADXRibbonButton constructor?
E.g.
this.myButton = new AddinExpress.MSO.ADXRibbonButton(this.components); |
|
Tobias B?hm
Posts: 73
Joined: 2009-07-06
|
Thanks, this was it.
Plus my variable that I assigned to the Id-Property hat a whitespace in it. Not a good idea. That caused the Ribbon to temporarily disappear (independent from my other open issue, but could it have something to do with it?)
Thanks |
|