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

Keyboard Events not firing.

4 Answers 170 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Karl Hunsley
Top achievements
Rank 1
Karl Hunsley asked on 26 May 2009, 01:23 PM
Hello,

I am using a masked edit control on my form, and would like to tie in some keyboard handling code to allow my userbase to operate the software without using a mouse.  However if I connect an event handler to the KeyDown/Up events my code is never executed.

My masked text box has a very simple mask of "######" and is in standard mode.  Just to make sure it was not me missing something, I placed a standard Winforms masked text box onto my form by the side of the Telerik control and this behaved as expected and fired the KeyUp/Down events.

I am using VS2008 SP1 and my project is set to use .Net V3.5.

Anyone got any ideas, I can not see any properties that need to be set in order to enable these events.  Its causing me a lot of trouble, as I will need to use quite a few of these controls to get my application  completed.

Best Regards,

Karl Hunsley

4 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 29 May 2009, 02:01 PM
Hello Karl Hunsley,

I hope that this will help. Here is a way to access the internal textbox used in the maskbox control.

     this.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.HostedControl.KeyDown += new KeyEventHandler(HostedControl_KeyDown);
   
You need to subscribe to KeyDown event. You can use the same logic for the other Key events of the control.

Please contact me again if you need more information.

Sincerely yours,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
José Miguel
Top achievements
Rank 1
answered on 10 Jun 2009, 06:14 AM
I'm still having the same problem even using the event keydown event that is described:

this.txtContrasenia.MaskedEditBoxElement.TextBoxItem.HostedControl.KeyDown +=new System.Windows.Forms.KeyEventHandler(HostedControl_KeyDown);

and the function ...

 

void HostedControl_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)

 

 

{

 

 

 

 if (e.KeyCode == Keys.Enter)

 

 

 

     MessageBox.Show("hello");

 

 

 

}

Additionally I'm getting this error when I try to view my Form in desgin mode (and I cannot see the Form):
Warning 1 Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located. C:\nettiers\SRFTBD\SRFTBD.Ventas.Forms\FormAutenticarUsuario.Designer.cs 93 0 

 

0
Boyko Markov
Telerik team
answered on 10 Jun 2009, 09:47 AM
Hello Jose Miguel,

I have attached a very simple sample application demonstrating how to subscribe to KeyDown event. The key thing here is to set the MaskType property to use this behavior because when MaskType is None the control doesn't work as a maskbox, but as a standard textbox. Please write me back if you need more information.

Greetings,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
José Miguel
Top achievements
Rank 1
answered on 10 Jun 2009, 07:17 PM
Thanks Boyko Markov, I realized about the problem.

Greetings,
José Gutiérrez
Tags
MaskedEditBox
Asked by
Karl Hunsley
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
José Miguel
Top achievements
Rank 1
Share this question
or