Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Buttons, RadioButton, CheckBox, etc > Highlight RadCheckBox when focused

Not answered Highlight RadCheckBox when focused

Feed from this thread
  • Chet Musialowski avatar

    Posted on Sep 12, 2011 (permalink)

    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 ?

    Thanks,
    Chet

    Reply

  • Ivan Petrov Ivan Petrov admin's avatar

    Posted on Sep 15, 2011 (permalink)

    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 >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Buttons, RadioButton, CheckBox, etc > Highlight RadCheckBox when focused
Related resources for "Highlight RadCheckBox when focused"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]