keyPress Event not firing

6 posts, 0 answers
  1. Louis
    Louis  avatar
    44 posts
    Member since:
    Sep 2007

    Posted 26 Sep 2007 Link to this post

    I'm trying to handle the KeyPress Event in the grid but it is never triggered ? I've tried the KeyUp and KeyDown too.
    Once i set the TabStop property to true, i get the KeyUp event triggered but then again the next cell is not selected.

    Question 1:
    How can i handle the tab being press to move in the grid?

    Question 2:
    I also see that when TabStop is set to false, pressing the tab key moves the focus to the next cell and if rows are available bellow will move the focus to the first cell of next row when being at the end of a row. But this does not trigger the CurrentRowChanged? Is this normal ?

  2. Jack
    Jack avatar
    2333 posts

    Posted 27 Sep 2007 Link to this post

    Hello Louis ,

    In order to enable processing of KeyPress and KeyDown events in your controls, set the Form's KeyPreview property to true. Nevertheless, the Tab key is a special key and it must be handled in ProcessCmdKey function which is not available as event.

    RadGridView has a property named StandardTab. When it is set to false (which is by default), the grid processes the Tab key and uses it to move through grid cells. If it is set to true, the grid does not process the Tab key. One issue is that the standard themes for the grid do not include a specific style for the selected cell. You will observe that something happens only when editing a cell. We made a custom theme based on our Vista theme that changes background of the selected cell to light yellow. You can find it attached here.

    Currently, the RadGridView does not support custom handling of keyboard messages, but we have this feature in mind and it will be implemented soon.

    In response to your second question, we did find some issues with the CurrentRowChanged event and the fixes will be available in our next service pack. Processing the Tab key does not depend on the TabStop property.

    Thank you for writing, and please, contact us again if we could be of any further assistance.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Martin
    Martin avatar
    18 posts
    Member since:
    Jul 2011

    Posted 18 Jun 2013 Link to this post

    In my grid the Keypress isn't firing either, although the forms' KeyPreview property is set to true. The grid itself lays on a radPageView. Could that have anything to do with it?
  4. Peter
    Peter avatar
    1157 posts

    Posted 21 Jun 2013 Link to this post

    Hi Martin,

    Thank you for writing.

    RadGridView processes keyboard events slightly different than other controls and the KeyPress event does not fire in the control. I can propose two different solutions for this case:
    1) Handle grid's PreviewKeyDown event.
    2) Create a custom GridBehavior which process the KeyPress event and replace the default GridBehavior with it:
    this.radGridView1.GridBehavior = new MyBehavior();
    public class MyBehavior : BaseGridBehavior
        public override bool ProcessKeyPress(KeyPressEventArgs keys)
            // ...
            return base.ProcessKeyPress(keys);

    I hope this helps.

    RadChart for WinForms is obsolete. Now what?
  5. Jorge
    Jorge avatar
    4 posts
    Member since:
    Sep 2012

    Posted 07 Oct 2013 Link to this post

    I have a workaround for this in VB:
    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
            Select Case keyData
                Case Keys.Enter
                    If ActiveControl.Name = "RadGridView1" Then
                    End If
                Case Keys.Escape
                Case Keys.F4
            End Select
            Return MyBase.ProcessCmdKey(msg, keyData)
    End Function

  6. Peter
    Peter avatar
    1157 posts

    Posted 10 Oct 2013 Link to this post

    Hello Jorge,

    Thank you for sharing your solution for this case with the community.

    I can confirm that ProcessCmdKey event (and also PreviewKeyDown event) can be used in this scenario.

    I hope this information helps.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top