We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Overriding a menu hotkey

Thread ID:

Created:

Updated:

Platform:

Replies:

94712 May 28,2010 02:50 PM UTC Jun 2,2010 04:32 AM UTC ASP.NET Web Forms (Classic) 2
loading
Tags: GridGroupingControl
Andy Chan
Asked On May 28, 2010 02:50 PM UTC

Hello,

I have assigned a hotkey (delete) to clear a range of cells. I want to change the behavior of the delete key when the user is in a cell's edit mode. I would like the delete key to behave normally in this state. Is there a way I can override the delete key as a hotkey?

I am using a generic toolstripmenu item in my toolbar:

ToolStripMenuItem item = new System.Windows.Forms.ToolStripMenuItem();

And I set the hotkey via the item's shortcutkeys property.
item.ShortcutKeys = shortcutKeys;

Currently, when I select a cell and go into edit mode, hitting the delete key will clear the contents of the entire cell. This isn't the behavior that I want. Please let me know if I can change this behavior, thanks!

Andy.

Andy Chan
Replied On May 28, 2010 04:57 PM UTC

sorry, this message should be posted to the essential grid -- windows forms section of the forum... can this be moved?

Rajadurai C [Syncfusion]
Replied On June 2, 2010 04:32 AM UTC

Hi Andy,

Thanks for your interest in Syncfusion Products.

In GridControl under cell edit mode, the default behavior of Delete key is, removing 1 character to the right of the caret position in cell on each key press which is the desired behavior for any editable controls. If the ActivateCurrentCellBehavior property is set to SelectAll, the cell selects entire contents on activation. With this, on pressing Delete key will delete the entire cell contents.

this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;

If you would like to handle this behavior and set the default with the SelectAll property, the following code can be handled in CurrentCellKeyDown event.

this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);

void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
TextBox tb = cc.Renderer.Control as TextBox;
tb.Select(0,0);
}
}


Here is a sample for your reference.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GC_DeleteKey2004313115.zip

If you want any other behavior to implement with certain keys, respective code can be handled in this event accordingly.

Regards,
Arulraj.A

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;