Keydown event on the RadribbonForm

3 posts, 0 answers
  1. JANG KYUNG SEOC
    JANG KYUNG SEOC avatar
    6 posts
    Member since:
    Nov 2008

    Posted 13 Oct 2009 Link to this post

    Hi,

    I use a RadribbonForm as a mybase.
    When I push one button Radribbonform changed to maximize dialog, and it will be topmost and have no button.

    For returning normal dialog, I want to use keydown event(Escape key). However it dosen't work.

    Can I get any sample source or example key event on the radribbonform?

    Thanks, 
  2. JANG KYUNG SEOC
    JANG KYUNG SEOC avatar
    6 posts
    Member since:
    Nov 2008

    Posted 14 Oct 2009 Link to this post

    I use below code for testing keydown event on the RadRibbonform

    Private Sub RadRibbonForm1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
            If e.KeyCode = Keys.Escape Then
                Me.Close()
            End If
    End Sub

    However it dose not work.
    Please let me know, how to use keydown event on the radribbonform.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 19 Oct 2009 Link to this post

    Hello JANG KYUNG SEOC,

    Thank you for writing.

    Actually if the form is not the control that has focus, then KeyPress isn't processed, so its not responding as in your case. I suggest you override and use ProcessCmdKey instead KeyDown event:

    protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
    {
     try
     {
         if (msg.WParam.ToInt32() == (int)Keys.Escape)
         {
             this.Close();
         }
         else
         {
             return base.ProcessCmdKey(ref msg, keyData);
         }
     }
     catch (Exception Ex )
     {
         MessageBox.Show("Key Overrided Events Error:"+ Ex.Message);
     }
     
     return base.ProcessCmdKey(ref msg,keyData);
    }

    Write me back if you have other questions.

    Kind regards,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top