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

RadCheckBox Problem on Enter KeyPress

4 Answers 134 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Kashif
Top achievements
Rank 1
Kashif asked on 30 Aug 2019, 09:52 PM

Dear Admins

I'm using Telerik UI for WinForms R2 2019 SP1.

Facing a problem in using RadCheckBox. When focus is on the CheckBox, ]Enter KeyPress Changes its ToggleState.

Then I Compare this behavior with Microsoft own CheckBox control, it was doing as required.

The Toggle State of ChcekBox should changes when MouseClick or SpaceBar key press.

My main requirement is to change the focus to next control on Enter Key Press.

 

4 Answers, 1 is accepted

Sort by
1
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 02 Sep 2019, 08:40 AM
Hello, Kashif,

To achieve this behavior, you should create a new checkbox element which inherits from the RadCheckBoxElement and change the logic for the Enter key in the OnKeyDown event. You should create a new checkbox control which inherits from the RadCheckBox control as well, and override the CreateButtonElement method in order to return the new checkbox element. Please refer to the following example:

public class MyCheckBoxElement : RadCheckBoxElement
{
    protected override void OnKeyDown(KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            return;
        }
        base.OnKeyDown(e);
    }
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadCheckBoxElement);
        }
    }
}
 
public class MyCheckBox : RadCheckBox
{
    protected override RadButtonElement CreateButtonElement()
    {
        return new MyCheckBoxElement();
    }
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadCheckBox).FullName;
        }
    }
}

After creating the new MyCheckBox control, you can find it in the Toolbox. If it doesn't appear in the Toolbox you can add a [Toolbox(true)] attribute to MyCheckBox class. 

I hope this helps. Should you have any other questions, I will be glad to help.

Regards,
Nadya
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.
0
Kashif
Top achievements
Rank 1
answered on 04 Sep 2019, 09:43 AM

Thank you for Example. Its Working now.

But i Think it is default behavior of CheckBox  for WIndows and Even for Linux Based Softwares.

and change should be made in the Control itself..

 

0
Nadya | Tech Support Engineer
Telerik team
answered on 05 Sep 2019, 10:27 AM
Hello Kashif,

Thank you for your feedback, we will consider implementing this if we receive more request for it. Any suggestions are very useful for us when discussing the features that the control should offer by default. 

Regards,
Nadya
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.
0
Kashif
Top achievements
Rank 1
answered on 05 Sep 2019, 12:03 PM
Thanks you
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Kashif
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Kashif
Top achievements
Rank 1
Share this question
or