Disable highlighting of the last selected button

3 posts, 1 answers
  1. Dominik
    Dominik avatar
    16 posts
    Member since:
    Oct 2019

    Posted 05 Dec 2019 Link to this post

    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. Answer
    Todor Vyagov
    Admin
    Todor Vyagov avatar
    40 posts

    Posted 09 Dec 2019 Link to this post

    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.
  3. Dominik
    Dominik avatar
    16 posts
    Member since:
    Oct 2019

    Posted 09 Dec 2019 Link to this post

    Hi Todor,

    Thank you very much, it worked perfectly.

    Kind Regards,

    Dominik

     

Back to Top