Ribbon control.Label and control.Image of button in ExcelDNA 0.26
Visto 1.785 veces
Saltar al primer mensaje no leído
KY
no leída,
7 jun 2010, 9:32:387/6/10
Responder al autor
Iniciar sesión para responder al autor
Reenviar
Iniciar sesión para reenviar
Eliminar
No tienes permiso para eliminar mensajes de este grupo
Copiar enlace
Denunciar mensaje
Mostrar el mensaje original
Las direcciones de correo electrónico de este grupo son anónimas o necesitas el permiso para ver las direcciones de correo electrónico de los miembros para poder ver el mensaje original
a Excel-Dna
Intellisense tells me there are 3 readonly properties on an
IRibbonControl; Context, Id and Tag. I want to change the image and
label when a user clicks a ribbon button, something like:
Public Sub OnButtonPressed(control as IRibbonControl)
If control.Id = "Button2" And control.Image = "Off" Then
Call ServerStartRTDServer()
control.Image = "On"
control.Label = "Real Time On"
Else
Call ServerTerminateRTDServer()
control.Image = "Off"
control.Label = "Real Time Off"
End If
End Sub
How do I get access to the ribbon images and labels outside of setting
them in customui.xml?
Govert van Drimmelen
no leída,
13 jun 2010, 8:08:4713/6/10
Responder al autor
Iniciar sesión para responder al autor
Reenviar
Iniciar sesión para reenviar
Eliminar
No tienes permiso para eliminar mensajes de este grupo
Copiar enlace
Denunciar mensaje
Mostrar el mensaje original
Las direcciones de correo electrónico de este grupo son anónimas o necesitas el permiso para ver las direcciones de correo electrónico de los miembros para poder ver el mensaje original
a Excel-Dna
Hi,
The Ribbon extensibility model is a bit unusual.
There is no opportunity to set the 'label' or 'image' property of the
button after it is created, but there are 'getLabel' and 'getImage'
callbacks that you can set up.
To get Excel to refresh your control (or the whole Ribbon extension)
you need to set an onLoad callback (on the customUI element) which
receives an IRibbonUI interface for you to keep. This interface has
two methods - Invalidate and InvalidateControl - which you call when a
control should be refreshed.
ExcelDna can helps with the implementation of the getImage callback -
call the ExcelRibbon.LoadImage method (probably as
base.LoadImage(imageId) in your code) with the imageId of the picture
you want to show - this way you can load the images you specify in
the .dna file.
All of this can be elegantly wrapped in some classes without too much
trouble.