ShortCut Key

Hi!

How to disable the shortcut key(Ctrl + X and etc)
of the GDBG.

Thanks!

1 Reply

AD Administrator Syncfusion Team September 5, 2006 09:41 AM UTC

Hi Lim,

One way to do this is to derive the grid and override ProcessCmdKey. Here is a code snippet

public class MyDataControl : GridDataBoundGrid
{
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if( ( keyData&Keys.Control )== Keys.Control || ( keyData&Keys.Shift )== Keys.Shift )
{
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

If you do not want to derive the grid, then you can handle CurrentCellControlKeyMessage. Please find the code snippet below.

//form Load...
this.grid.CurrentCellControlKeyMessage +=new GridCurrentCellControlKeyMessageEventHandler(CurrentCellControlKeyMessage);

private void CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e)
{
if(( (Control.ModifierKeys & Keys.Shift) != 0 )|| ((Control.ModifierKeys & Keys.Control) != 0 ))
{
e.Handled = true;
e.Result = true;
}
}

Let me know if this helps.
Best Regards,
Haneef

Loader.
Up arrow icon