RadGridView KeyDown Event doesn't respond when holding Ctrl

7 posts, 0 answers
  1. Dan
    Dan avatar
    17 posts
    Member since:
    Mar 2006

    Posted 12 Apr 2012 Link to this post

    I have a piece of code that refreshes the grid when the user hits ctrl+r, but this has stopped working between 2011 Q3 SP1 and 2012 Q1 SP1.  The event fires when I press R or other keys alone, but holding ctrl while pressing does not work.  The shortcuts for cut, paste, copy work with the ctrl button held.
  2. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 17 Apr 2012 Link to this post

    Hi Daniel,

    Thank you for writing.

    One way to handle this key combination is to handle the PreviewKeyDown event of RadGridView:
    void radGridView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
    {
        if (e.Modifiers == Keys.Control && e.KeyCode == Keys.R)
        {
      //your logic here
        }
    }

    Please give this approach a try and let me know how this works for you.
     
    Regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Dan
    Dan avatar
    17 posts
    Member since:
    Mar 2006

    Posted 17 Apr 2012 Link to this post

    Thanks for your reply.  I was told by another member of the support team that implementing a custom behavior that overrides ProcessKeyDown would also work, and I have implemented my solution using that.

    public class KeyDownBehavior : BaseGridBehavior
    {
          public override bool ProcessKeyDown(KeyEventArgs keys)
          {
               if (keys.Control && keys.KeyCode == Keys.R)
               {
                        //do something here
               }
               return base.ProcessKeyDown(keys);
          }
    }
  4. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 20 Apr 2012 Link to this post

    Hi Daniel,

    That is absolutely correct. Feel free to use the custom behavior approach.

    We kindly ask you to use just one support channel to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to the license type and the time of posting, so if it is an urgent problem, we suggest opening a support ticket, which would be handled before a forum thread.

    Thank you for your understanding.

    Regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  5. Joe Sugden
    Joe Sugden avatar
    53 posts
    Member since:
    Feb 2010

    Posted 12 Jun 2012 Link to this post

    This is not working in the new Release 2012 Q2 either.
    We initially had in as described in :
    http://www.telerik.com/support/kb/winforms/gridview/implementing-copy-paste-to-excel-functionality-in-radgridview-for-winforms.aspx 

    but now KeyDown Event doesn't respond when holding Ctrl

    The PreviewKeyDown does not do us any good because after we copy to clipboard in there, the grid autmatically overwrites it with it's own copy functionality.

    Now what???


  6. Joe Sugden
    Joe Sugden avatar
    53 posts
    Member since:
    Feb 2010

    Posted 13 Jun 2012 Link to this post

    Well inheriting from BaseGridBehavior works, but still there is a bug with grid key events...
  7. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 15 Jun 2012 Link to this post

    Hello Daniel,

    In regards to the events, the KeyDown/PreviewKeyDown event does expose some of the pressed keys, however, if you want to have a full control, you should use the GridBehavior.

    In regards to the embedded copy/paste functionality, you can disable it by using the following code:
    radGridView1.ClipboardCopyMode = Telerik.WinControls.UI.GridViewClipboardCopyMode.Disable;

    I hope this helps.

    All the best,
    Stefan
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top