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

Keydown event on the RadribbonForm

2 Answers 109 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
JANG KYUNG SEOC
Top achievements
Rank 1
JANG KYUNG SEOC asked on 14 Oct 2009, 04:50 AM
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 Answers, 1 is accepted

Sort by
0
JANG KYUNG SEOC
Top achievements
Rank 1
answered on 15 Oct 2009, 12:36 AM
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.
0
Martin Vasilev
Telerik team
answered on 19 Oct 2009, 07:02 AM
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.
Tags
RibbonBar
Asked by
JANG KYUNG SEOC
Top achievements
Rank 1
Answers by
JANG KYUNG SEOC
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or