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

Focus cue for RadCheckbox with no label

2 Answers 39 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Lou
Top achievements
Rank 1
Lou asked on 10 Feb 2015, 11:04 PM
Hi, I have some RadCheckboxes that have no labels. When I tab to them there is no visual indication that these checkboxes have focus. Is there a way to do this?
I do have "AllowShowFocusCues" set to True.

Thanks,

-Lou

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 13 Feb 2015, 04:47 PM
Hello Lou,

Thank you for writing.

In this case I would suggest that you subscribe to the GotFocus and LostFocus events. In the handlers you can define a proper setting so that it will become obvious if the check box is on focus or not. In my example I am changing the ForeColor property of the CheckMarkPrimitive object. Please refer to the following sample: 
public partial class Form1 : Form
{
    private Color defaultColor;
     
    public Form1()
    {
        InitializeComponent();
 
        this.radCheckBox1.GotFocus +=radCheckBox_GotFocus;
        this.radCheckBox1.LostFocus += radCheckBox_LostFocus;
        this.radCheckBox2.GotFocus += radCheckBox_GotFocus;
        this.radCheckBox2.LostFocus += radCheckBox_LostFocus;
        this.radCheckBox3.GotFocus += radCheckBox_GotFocus;
        this.radCheckBox3.LostFocus += radCheckBox_LostFocus;
    }
 
    private void radCheckBox_LostFocus(object sender, EventArgs e)
    {
        RadCheckBox checkBox = sender as RadCheckBox;
        checkBox.ButtonElement.CheckMarkPrimitive.Border.ForeColor = this.defaultColor;
    }
 
    private void radCheckBox_GotFocus(object sender, EventArgs e)
    {
        RadCheckBox checkBox = sender as RadCheckBox;
        this.defaultColor = checkBox.ButtonElement.CheckMarkPrimitive.Border.ForeColor;
        checkBox.ButtonElement.CheckMarkPrimitive.Border.ForeColor = Color.Red;
    }
}

I am also attaching a gif file showing the result on my end.

I hope this helps. Should you have further questions, please do not hesitate to write back.


Regards,
Hristo Merdjanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Lou
Top achievements
Rank 1
answered on 13 Feb 2015, 08:25 PM
That's cool - thanks for the help Hristo.

-Lou
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Lou
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Lou
Top achievements
Rank 1
Share this question
or