RadDatetimePicker KeyDown event doesn't fire

7 posts, 0 answers
  1. kenghot
    kenghot avatar
    31 posts
    Member since:
    Feb 2007

    Posted 23 Jan 2012 Link to this post

    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
  2. kenghot
    kenghot avatar
    31 posts
    Member since:
    Feb 2007

    Posted 25 Jan 2012 Link to this post

    Pleazzzz !! I need help
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 26 Jan 2012 Link to this post

    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).

  5. Shoshana
    Shoshana avatar
    2 posts
    Member since:
    Feb 2013

    Posted 20 Feb 2013 Link to this post

    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

  6. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 22 Feb 2013 Link to this post

    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.
  7. Shoshana
    Shoshana avatar
    2 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    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
  8. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 28 Feb 2013 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready