This is a migrated thread and some comments may be shown as answers.

Disable highlighting of the last selected button

2 Answers 1478 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Dominik
Top achievements
Rank 1
Dominik asked on 05 Dec 2019, 09:54 AM

Hi

Is there a way to disable the highlighting of the last selected button?

With:

        private void button_changebackcolor(object sender, System.EventArgs e)
        {
            if(((Telerik.WinControls.UI.RadButton)sender).BackColor != System.Drawing.Color.White)
            {
                ((Telerik.WinControls.UI.RadButton)sender).BackColor = System.Drawing.Color.White;
            }
        }

it's possible, but that makes problem with my real program, because sometimes I need to highlight a button with yellow and button_changebackcolor overrrides that.

 

Thank you in Advance

Kind Regards,

Dominik

2 Answers, 1 is accepted

Sort by
0
Accepted
Todor
Telerik team
answered on 09 Dec 2019, 02:53 PM

Hello Dominik,

The back color in MaterialBlueGrey theme indicates that the button is focused and if the user presses the enter or space keys, the button will be clicked.
There are two options to remove this focus back color:

  1. Prevent the button from gaining focus by setting its Focusable and TabStop properties to false:
    this.radButton1.Focusable = false;
    this.radButton1.TabStop = false;
  2. Override the settings of the theme using ThemeValueOverride(IsDefault state indicates that the button has focus):
    this.radButton1.ButtonElement.SetThemeValueOverride(FillPrimitive.BackColorProperty, Color.White, "IsDefault", typeof(FillPrimitive));
    this.radButton1.ButtonElement.SetThemeValueOverride(FillPrimitive.BackColorProperty, Color.FromArgb(236, 236, 236), "IsDefault.MouseOver", typeof(FillPrimitive));
    this.radButton1.ButtonElement.SetThemeValueOverride(FillPrimitive.BackColorProperty, Color.FromArgb(224, 224, 224), "IsDefault.Pressed", typeof(FillPrimitive));
    For more information about overriding theme settings visit our help article: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/override-theme-settings-at-run-time

I hope this helps. Should you have any other questions, do not hesitate to ask.

Regards,
Todor Vyagov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dominik
Top achievements
Rank 1
answered on 09 Dec 2019, 03:46 PM

Hi Todor,

Thank you very much, it worked perfectly.

Kind Regards,

Dominik

 

Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Dominik
Top achievements
Rank 1
Answers by
Todor
Telerik team
Dominik
Top achievements
Rank 1
Share this question
or