[VB.Net] Reload/Update Dynamic Gallery in PowerPoint

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

[VB.Net] Reload/Update Dynamic Gallery in PowerPoint
 
Christian Fasold




Posts: 45
Joined: 2013-11-27
Hello everybody,

I have a gallery in PowerPoint 2007/2010/2013, which I fill dynamically at the beginning when the addin is loaded. That works pretty well.
Here is an excerpt of a loop where I create the gallery items and fill the gallery:

 Dim tempName As String = templateThumbs.ToString + "" + "Folie" + i.ToString + "." + templateThumbsExtension.ToString  ' Generate the next filename
 Dim tempImage = Image.FromFile(tempName)    ' Load the image
 tempImage = util_ResizeImage(tempImage, "0,125", "0,125", Drawing2D.InterpolationMode.HighQualityBicubic) ' Resize the image
 AdxRibbonGalleryTemplates.ItemHeight = tempImage.Height ' Set the image size corresponding to the actual images
 AdxRibbonGalleryTemplates.ItemWidth = tempImage.Width    ' Set the image size corresponding to the actual images
 ImageListTemplates.ImageSize = New Size(tempImage.Width, tempImage.Height) ' Set the image size corresponding to the actual images
 ImageListTemplates.Images.Add(tempImage)    ' Add the image to the imageList
 Dim AdxRibbonButton1 As AddinExpress.MSO.ADXRibbonButton = New AddinExpress.MSO.ADXRibbonButton ' Create the dynamic button
 AdxRibbonButton1.ImageList = ImageListTemplates     ' Apply the imageList
 AdxRibbonButton1.Image = i - 1                      ' Get the correct image from the imageList
 AdxRibbonButton1.Caption = "Slide " & i             ' Add the caption
 AdxRibbonGalleryTemplates.Items.Add(AdxRibbonButton1)   ' Add the button to the gallery


So I run this function at the beginning when the addin is loaded and the gallery get filled perfectly OK.
But when I run the exact same function again (because the grafic files have changed during runtime), I can see no changes at all...

--> Help ;-)

What will I need to do to get the update working?

Thanks a lot in advance!

Best regards,

Chris
Posted 04 Feb, 2014 06:21:18 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Chris,

The Ribbon is a static thing mostly. Try modifying the properties of the existing button rather than creating a new one.

FYI, the only way to create Ribbon controls at run time is to use the ADXRibbonMenu component and set its Dynamic property to true. In this case, it fires the OnCreate event whenever you open the menu.


Andrei Smolin
Add-in Express Team Leader
Posted 04 Feb, 2014 07:16:20 Top
Christian Fasold




Posts: 45
Joined: 2013-11-27
Andrej,

thanks for your reply.
That was a good idea, as long as the amount of buttons inside the gallery stays the same, I now update them.
It is unfortunate that I cannot add new elements (or delete some) during runtime... But the solution now
is quite OK so far :)

Best regards,

Chris
Posted 07 Feb, 2014 03:53:36 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
That's great!


Andrei Smolin
Add-in Express Team Leader
Posted 07 Feb, 2014 04:40:02 Top