RadButton ResetValue is not working on BackColor2,BackColor3, and BackColor4

1 Answer 52 Views
Buttons, RadioButton, CheckBox, etc
Top achievements
Rank 1
y2kdis asked on 31 Jul 2023, 05:24 PM


I'm trying to retain the background color of a button on the click event to indicate it's the last button that was selected. Clicking another button should reset the first button then highlight the second button. All four backcolor assignments work fine, but on the reset side only the first backcolor property seems to work.

        Dim theme As Theme = ThemeRepository.FindTheme(Me.myButton.ThemeName)
        Dim repository As StyleRepository = theme.FindRepository("ButtonMouseDownFill")
        Dim setting As PropertySetting
        Dim bColor As Color, bColor2 As Color, bColor3 As Color, bColor4 As Color

        setting = repository.FindSetting("BackColor") : bColor = CType(setting.EndValue, Color)
        setting = repository.FindSetting("BackColor2") : bColor2 = CType(setting.EndValue, Color)
        setting = repository.FindSetting("BackColor3") : bColor3 = CType(setting.EndValue, Color)
        setting = repository.FindSetting("BackColor4") : bColor4 = CType(setting.EndValue, Color)

        Select Case buttonName
            Case Me.btnFirst.Name
                Me.btnSecond.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
                Me.btnSecond.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColor2Property, ValueResetFlags.Local)    '<-- doesn't work
                Me.btnSecond.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColor3Property, ValueResetFlags.Local)    '<-- doesn't work
                Me.btnSecond.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColor4Property, ValueResetFlags.Local)    '<-- doesn't work

                Me.btnFirst.ButtonElement.ButtonFillElement.BackColor = bColor
                Me.btnFirst.ButtonElement.ButtonFillElement.BackColor2 = bColor2
                Me.btnFirst.ButtonElement.ButtonFillElement.BackColor3 = bColor3
                Me.btnFirst.ButtonElement.ButtonFillElement.BackColor4 = bColor4

            Case Me.btnSecond.Name
                Me.btnFirst.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
                Me.btnFirst.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColor2Property, ValueResetFlags.Local)    '<-- doesn't work
                Me.btnFirst.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColor3Property, ValueResetFlags.Local)    '<-- doesn't work
                Me.btnFirst.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColor4Property, ValueResetFlags.Local)    '<-- doesn't work

                Me.btnSecond.ButtonElement.ButtonFillElement.BackColor = bColor
                Me.btnSecond.ButtonElement.ButtonFillElement.BackColor2 = bColor2
                Me.btnSecond.ButtonElement.ButtonFillElement.BackColor3 = bColor3
                Me.btnSecond.ButtonElement.ButtonFillElement.BackColor4 = bColor4

        End Select

1 Answer, 1 is accepted

Sort by
Dinko | Tech Support Engineer
Telerik team
answered on 03 Aug 2023, 11:05 AM

Hi Sidky Macatangay,

All 4 properties BackColor, BackColor2, BackColor3, and BackColor4 are used for applying a gradient color to the control. By default, the GradientStyle property is set to Solid. This means that only BackColor will be used to style the control. If you set it to Linear, the number of colors applied to the control depends on the NumberOfColors property. Are you using a gradient? If not, you can remove the settings of these properties.

I have tested your approach in a sample project and it is working. The project has only 1 color as a backcolor and does not use gradients. You can check it and let me know if I am in the right direction. 

Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Top achievements
Rank 1
commented on 04 Aug 2023, 04:45 PM

The goal is to keep the entire surface in its darkened/highlighted color state as if the mouse-click was never released, which is why BackColor2, BackColor3, and BackColor4 were included in my color assignment.

Setting only the BackColor property will make the button retain the color highlights only on the top side.

Circling back to the issue, how come the color assignments for BackColor2 to BackColor4 worked as expected,  but the ResetValue for them didn't produce the intended result like it did for BackColor?

Dinko | Tech Support Engineer
Telerik team
commented on 07 Aug 2023, 11:27 AM

Thank you for the additional clarifications. I see what you mean here.  The BackColor property is inherited from the LightVisualElement. However, the rest of the BackColor properties (BackColor2, BackColor3, BackColor4) are exposed in the FillPrimitive class which the ButtonFillElement property is of type. In this particular case, we are resetting the wrong properties. You can change the class from which these properties are coming from.

. . . . . 
Select Case button.Name
    Case Me.RadButton1.Name
        Me.RadButton2.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
        Me.RadButton2.ButtonElement.ButtonFillElement.ResetValue(FillPrimitive.BackColor2Property, ValueResetFlags.Local)    '<-- doesn't work
        Me.RadButton2.ButtonElement.ButtonFillElement.ResetValue(FillPrimitive.BackColor3Property, ValueResetFlags.Local)    '<-- doesn't work
        Me.RadButton2.ButtonElement.ButtonFillElement.ResetValue(FillPrimitive.BackColor4Property, ValueResetFlags.Local)    '<-- doesn't work

        Me.RadButton1.ButtonElement.ButtonFillElement.BackColor = bColor
        Me.RadButton1.ButtonElement.ButtonFillElement.BackColor2 = bColor2
        Me.RadButton1.ButtonElement.ButtonFillElement.BackColor3 = bColor3
        Me.RadButton1.ButtonElement.ButtonFillElement.BackColor4 = bColor4

    Case Me.RadButton2.Name
. . . . . .  .

Top achievements
Rank 1
commented on 07 Aug 2023, 06:11 PM

Thank you very much! No chance I would have figured that out by myself.
Buttons, RadioButton, CheckBox, etc
Asked by
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question