Highlight RadCheckBox when focused

2 posts, 0 answers
  1. Chet Musialowski
    Chet Musialowski avatar
    19 posts
    Member since:
    Nov 2009

    Posted 12 Sep 2011 Link to this post

    I'm using RadControls for WinForms  Q2 2011 (version 2011.2.11.831)  and would like to highlight the Checkbox when it has focus to make it easier for my users to find the focused field.  I have code working with the Enter/Leave events for RadButtons and RadDropDownLists but am unable to get it working for the RadCheckBox.  I've tried using the BackColor/ForeColor properties of the ButtonElement.ButtonFillElement object but to no avail.

    Here is my class code for the RadButton:
    this.Enter += new EventHandler(BaseButton_Enter);
    this.Leave += new EventHandler(BaseButton_Leave);
    void BaseButton_Enter(object sender, EventArgs e)
          this.ButtonElement.ButtonFillElement.BackColor = Color.Blue;
          this.ButtonElement.ForeColor = Color.White;
          this.ButtonElement.ButtonFillElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    void BaseButton_Leave(object sender, EventArgs e)
          this.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
          this.ButtonElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
          this.ButtonElement.ButtonFillElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);

    How can I do a similar effect for the RadCheckBox.

    Secondly, I'd actually like to not hard code the colors, but to use the Selected Text Color of the TextBox (I'm assuming this comes from the Theme in use).  How do I access the information ?

  2. Ivan Petrov
    Ivan Petrov avatar
    718 posts

    Posted 15 Sep 2011 Link to this post

    Hi Chet,

    Thank you for writing and for the provided code snippet.

    You can achieve this behavior in RadCheckBox in almost the same way you did for RadButton. Consider the following code snippet which demonstrates how:

    this.radCheckBox1.Enter += new EventHandler(radCheckBox1_Enter);
    this.radCheckBox1.Leave += new EventHandler(radCheckBox1_Leave);
    void radCheckBox1_Leave(object sender, EventArgs e)
      this.radCheckBox1.BackColor = Color.Transparent;
      this.radCheckBox1.ButtonElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
    void radCheckBox1_Enter(object sender, EventArgs e)
      this.radCheckBox1.BackColor = Color.Blue;
      this.radCheckBox1.ButtonElement.ForeColor = Color.White;

    As to your second inquiry, the theme information is stored in the theme files and cannot be accessed at  runtime.

    I hope this will help you out. If you have further questions, I would be glad to help.

    Best wishes,
    Ivan Petrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top