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
1
Accepted
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:
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
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
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
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