Hi.
I want to bring a custom control that inherits from RasMaskedEditBox. But onKeyDown and OnKeyPress events do not fired.
public class myMask: Radmaskededitbox
{
protected override void OnKeyDown(KeyEventArgs e)
{
//My codes
}
}
1 Answer, 1 is accepted
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 May 2021, 01:36 PM
Hi, Roh,
RasMaskedEditBox internally hosts the standard MS TextBox. Hence, it handles the keyboard input. The following code snippet demonstrates how to handle the KeyDown event in the hosted control:
Hi. Thanks a lot for your reply. I tried your sample code and I think it is incomplete or I did not ask my questions correctly. Is it possible to give an accurate example that is practical? I want to write an override function for the OnKeyDown event from a class inherited from the Radmaskededitbox class
Dess | Tech Support Engineer, Principal
Telerik team
commented on 23 Aug 2021, 08:39 AM
Hi, Roh,
Since RadMaskedEditBox internally hosts the standard MS TextBox, the hosted control handles the keyboard input first. Then, the message is passed to the RadMaskedEditBox and RadMaskedEditBoxElement respectively. It is possible to suppress the keyboard's input from the hosted text box. Thus, you can implement your logic in the overridden OnKeyDown method from RadMaskedEditBox:
I believe that it would fit your custom scenario. However, if you are still experiencing any further difficulties, it would be greatly appreciated if you can provide more details about the exact goal that you are trying to achieve. Thus, we would be able to get better understanding of the precise case and think about a suitable solution. Thank you in advance.