DataGrid - Catching backspace key click before its processed.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Colin Jack (colin.jack_at_ed.tadpole.com)
Date: 07/08/04


Date: Thu, 8 Jul 2004 10:34:41 +0100

Hi,

I am trying to catch the user clicking the backspace key, Keys.Back. I need
to do this as I cant allow the datagrid to add a new blank row when the user
clicks the backspace key whilst they are in the last row in the grid, if the
row is also empty. Anyway I've derived my own custom control from the
DataGrid and want to pre process the backspace key. However I've found that
I'm not catching the backspace with any of these overrides:

 public override bool PreProcessMessage(ref Message msg)
 protected override bool ProcessKeyMessage(ref Message m)
 protected override bool ProcessKeyEventArgs(ref Message m)
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 protected override bool ProcessDialogKey(Keys keyData)
 protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message
msg)

The problem is none of these methods is getting called when I click the
backspace, it seems like the DataGrid is immediately processing it. I'm a
little confused over this as I also needed to handle the Delete key,
Keys.Delete. I managed to do this as the ProcessKeyPreview is raised when
the user clicks the Delete key so I have no idea why it isnt raised for the
backspace key.

Anyone got any suggestions?

Ta,

Colin Jack



Relevant Pages

  • Re: DataGrid - Preprocessing the backspace key.
    ... > I am trying to catch the user clicking the backspace key, ... > DataGrid and want to pre process the backspace key. ... > protected override bool ProcessKeyEventArgs ... > protected override bool ProcessCmdKey(ref Message msg, ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • DataGrid - Preprocessing the backspace key.
    ... I am trying to catch the user clicking the backspace key, ... DataGrid and want to pre process the backspace key. ... protected override bool ProcessKeyEventArgs ... protected override bool ProcessCmdKey(ref Message msg, ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: DataGrid - Preprocessing the backspace key.
    ... >> DataGrid and want to pre process the backspace key. ... >> protected override bool ProcessKeyEventArgs ... >> protected override bool ProcessCmdKey(ref Message msg, ... >> Colin Jack ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: KeyPress at DataGrid
    ... One way you can do this is to derive the datagrid and override ... protected override bool ProcessCmdKey(ref Message msg, Keys keyData) ...
    (microsoft.public.dotnet.framework.windowsforms)