radcheckbox checking

1 Answer 17 Views
CheckedListBox
darin
Top achievements
Rank 1
Iron
Iron
darin asked on 06 Mar 2022, 06:12 PM

In our application, we were using the standard windows CheckBox.

We have an Overrides onkeypress to trap the ENTER key and send a TAB (so enter moves to the next field on the form). This works great, and for the user to toggle a checked/non-checked state, the space bar is hit.

When using the RadCheckBox, the space bar still changes the checked state, but also when i hit ENTER, it changes the checked state and moves to the next field. 

I do not want it to change the checked state on the ENTER, i only want it to move to the next field.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Mar 2022, 08:50 AM
Hello, Darin,

It is possible to create a derivative of RadCheckBox and override its OnKeyDown method which toggles the state, prevent the base logic and perform the desired action. I have prepared a sample code snippet for your reference:
        public class CustomRadCheckBox : RadCheckBox
        {
            public override string ThemeClassName  
            { 
                get 
                { 
                    return typeof(RadCheckBox).FullName;  
                }
            }

            protected override void OnKeyDown(KeyEventArgs e)
            {
                if (e.KeyData == Keys.Enter)
                {
                    SendKeys.Send("{TAB}");
                    return;
                }
                base.OnKeyDown(e);
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

darin
Top achievements
Rank 1
Iron
Iron
commented on 07 Mar 2022, 07:16 PM

Thanks. I was doing onkeypress instead of onkeydown.
Tags
CheckedListBox
Asked by
darin
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or