Ryan Farley
Guest
|
In my addin, I would like to store the definitions of the buttons in the addin in a database and then create them at runtime.
I have this almost working, except it is just not quite right. The newly added button is there, but it just doesn't show. If I cause a MessageBox to fire then the button shows (once the MessageBox has been closed). From that point all is well and the button works fine.
The code to add the button is simple enough:
ADXCommandBarButton button = new ADXCommandBarButton();
button.Caption = "Some button 1";
button.ControlTag = new Guid("dddddddd-dddd-dddd-dddd-dddddddddddd").ToString();
button.Style = ADXMsoButtonStyle.adxMsoButtonCaption;
button.Temporary = true;
button.UpdateCounter = 10;
button.Click += new ADXClick_EventHandler(this.buttonGeneric_Click);
adxOlExplorerCommandBar1.Controls.Add(button);
Like I said, the button is there, just doesn't show until something else happens. Is there some way I can invalidate the addin to cause it to repaint or something? Know what I mean? |
|
Matt Driver
Matt
Posts: 152
Joined: 2004-08-17
|
Hi
I used to have a similar issue what I actually did in the end was to chance the width of a button by one pixel and then put it back so:
button.width = button.width - 1;
button.width = button.width + 1;
give it a go.
Matt |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|
Ryan Farley
Guest
|
Thanks guys,
Using the sample code I posted before, here's what changed for it to work:
ADXCommandBarControl ctrl = adxOlExplorerCommandBar1.Controls.Add(
typeof(ADXCommandBarButton),
new Guid("dddddddd-dddd-dddd-dddd-dddddddddddd").ToString(),
1,
0,
true);
ADXCommandBarButton button = ctrl.AsButton;
button.Caption = "Some button 1";
button.Style = ADXMsoButtonStyle.adxMsoButtonCaption;
button.Temporary = true;
button.UpdateCounter = 10;
button.Click += new ADXClick_EventHandler(this.buttonGeneric_Click);
Basically, added to the container first, then set the properties of the returned control.
All good now. Thanks. |
|