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

RadDatetimePicker KeyDown event doesn't fire

6 Answers 283 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
kenghot
Top achievements
Rank 1
kenghot asked on 23 Jan 2012, 12:35 PM
Hi,
I'm using RadDatetimePicker RadWinForm  Q3 2011 . My problem is KeyDown event doesn't fire when user press "Enter". How can i solve this problem .

my code is :

 Private Sub IctDateTimePicker1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles IctDateTimePicker1.KeyDown
                If e.KeyCode = Keys.Enter Then
                    SendKeys.SendWait("{TAB}")
                End If
    End Sub

Best Regards,
Kenghot

6 Answers, 1 is accepted

Sort by
0
kenghot
Top achievements
Rank 1
answered on 26 Jan 2012, 05:35 AM
Pleazzzz !! I need help
0
Peter
Telerik team
answered on 26 Jan 2012, 09:53 AM
Hello Kenghot,

You should handle KeyPress event instead of KeyDown event because the Enter key is processed in different way. Consider the sample below:

Private Sub IctDateTimePicker1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles IctDateTimePicker1.KeyPress
                If Asc(e.KeyChar) = 13 Then
                    SendKeys.SendWait("{TAB}")
                End If
End Sub

I hope it helps. Don't hesitate to contact us, if you have further questions.

Kind regards,
Peter
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

0
Shoshana
Top achievements
Rank 1
answered on 20 Feb 2013, 06:16 AM
Hi,
I'm using RadDatetimePicker RadWinForm Q2 2011 .
My problem is KeyDown/KeyPress events doesn't fire when user press "Delete". How can i solve this problem ?
I tried override and subscribe, but its doesn't work

Please, I need help!
Thanks in advance

Shoshana

0
Peter
Telerik team
answered on 22 Feb 2013, 02:25 PM
Hi Shoshana,  

Thank you for contacting Telerik support.

You should handle the hosted textbox control
KeyDown Event:
this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl.KeyDown += new   KeyEventHandler(HostedControl_KeyDown);
 
 
 void HostedControl_KeyDown(object sender, KeyEventArgs e)
 {
      
 }
I hope this helps.

All the best,
Peter
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Shoshana
Top achievements
Rank 1
answered on 26 Feb 2013, 06:48 AM
Hi,
Thanks for your reply,
but this code works only when subscribe to the event out of the DateTime class,
but when I write this code, its does not work

public DateTimePickerBaseTest()
           : base()
       {
           this.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl.KeyDown += new KeyEventHandler(HostedControl_KeyDown);
       }
 
       void HostedControl_KeyDown(object sender, KeyEventArgs e)
       {
           if (e.KeyData == System.Windows.Forms.Keys.Delete)
           {
               this.SetToNullValue();
 
               //this.OnNotifyPropertyChanged("BindableValue");
 
               e.Handled = true;
           }
 
           else
               base.OnKeyDown(sender, e);
       }


I'd be happy to use your help again,
Shoshana
0
Peter
Telerik team
answered on 28 Feb 2013, 03:16 PM
Hi Shoshana,

Thank you for writing back.

I guess at this point the textbox is not yet initialized. 
I would like to recommend you to subscribe to the event in the OnLoad override:
protected override void OnLoad(System.Drawing.Size desiredSize)
{
            base.OnLoad(desiredSize);
            this.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl.KeyDown += new KeyEventHandler(HostedControl_KeyDown);
}

I hope this helps.

Greetings,
Peter
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
kenghot
Top achievements
Rank 1
Answers by
kenghot
Top achievements
Rank 1
Peter
Telerik team
Shoshana
Top achievements
Rank 1
Share this question
or