Change the Image of Button

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

Change the Image of Button
 
Frederik Handschuh




Posts: 20
Joined: 2023-08-07
Good day, is it possible to change the image of a button at runtime?

I've tried it in the source code with "Image", "Imagelist", and "Glyph", but unfortunately without success. The background is that the entire ribbon is supposed to be built dynamically. Here, I've implemented a temporary solution by adjusting the caption and the event of the button at runtime, but unfortunately changing the image doesn't work.
Posted 03 Sep, 2023 09:14:34 Top
Andrei Smolin


Add-in Express team


Posts: 19122
Joined: 2006-05-11
Hello Frederik,

Make sure that you follow the schema that we describe in section Updating custom Ribbon controls at run time; see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Sep, 2023 14:42:15 Top
Frederik Handschuh




Posts: 20
Joined: 2023-08-07
When is the PropertyChange event triggered? I'm using the following code:




 btn2.Visible = True
btn2.Caption = FMT0("FT_8")
Dim img As Image
Using ms As New MemoryStream(My.Resources.symbol_questionmark1)
     img = Image.FromStream(ms)
End Using
'Dim img As Image =
curerntimg = New Bitmap(img)
btn2.Glyph = img
AddHandler btn2.OnClick, AddressOf Risikobefragung_OnClick
buttonCount = buttonCount + 1






 Private Sub btn1_PropertyChanging(sender As Object, e As ADXRibbonPropertyChangingEventArgs) Handles btn1.PropertyChanging, btn9.PropertyChanging, btn8.PropertyChanging, btn7.PropertyChanging, btn6.PropertyChanging, btn5.PropertyChanging, btn4.PropertyChanging, btn3.PropertyChanging, btn2.PropertyChanging, btn17.PropertyChanging, btn16.PropertyChanging, btn15.PropertyChanging, btn14.PropertyChanging, btn13.PropertyChanging, btn12.PropertyChanging, btn11.PropertyChanging, btn10.PropertyChanging
        Dim condition
        Select Case e.PropertyType
            Case ADXRibbonControlPropertyType.Caption
                If condition Then
                    e.Value = "Some caption"

                Else
                    e.Value = "Some other caption"
                End If
            Case ADXRibbonControlPropertyType.Enabled
                If condition Then
                    e.Value = True

                Else
                    e.Value = False
                End If
            Case ADXRibbonControlPropertyType.Glyph
                e.Value = curerntimg
        End Select
    End Sub
Posted 05 Sep, 2023 15:09:31 Top
Andrei Smolin


Add-in Express team


Posts: 19122
Joined: 2006-05-11
Hi Frederik,

I've created a sample project; download it at https://temp.add-in-express.com/support/MyAddin25_Frederik_Handschuh.zip.

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Sep, 2023 09:20:26 Top
Frederik Handschuh




Posts: 20
Joined: 2023-08-07
thanks
Posted 09 Sep, 2023 08:47:05 Top