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

Highlight RadCheckBox when focused

1 Answer 106 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Chet Musialowski
Top achievements
Rank 1
Chet Musialowski asked on 12 Sep 2011, 04:52 PM
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

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 15 Sep 2011, 12:40 PM
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 >>

Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Chet Musialowski
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or