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.
Unfortunately, activation email could not send to your email. Please try again.

CutPaste

Thread ID:

Created:

Updated:

Platform:

Replies:

52788 Dec 4,2006 12:47 PM Dec 5,2006 06:46 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 4, 2006 12:47 PM

Hi,

How can i control CTRL+X or CTRL+V in KeyDown Event...

Thanks,
Surti

Administrator [Syncfusion]
Replied On December 4, 2006 11:18 PM

Hi Surti,

To control the +V,+C keystroke in KeyDown event, you need to find the keystroke and set e.Handled = true to cancel the default behavior. Here is a code snippet to show this.

private void gridControl1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
Keys modifierKeys = Control.ModifierKeys;
Keys keyCode = e.KeyCode & Keys.KeyCode;
bool controlKeyDown = (e.Modifiers & Keys.Control) != Keys.None;
bool menuKeyDown = (e.Modifiers & Keys.Menu) != Keys.None;
switch (keyCode)
{
case Keys.V: // +V
if (controlKeyDown && !menuKeyDown)
{
Console.WriteLine("+V Pressed");
e.Handled = true;
}
break;
case Keys.C: // +C
if (controlKeyDown && !menuKeyDown)
{
Console.WriteLine("+C Pressed");
e.Handled = true;
}
break;
case Keys.X: // +X
if (controlKeyDown && !menuKeyDown)
{
Console.WriteLine("+X Pressed");
e.Handled = true;
}
break;
}
}
}

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On December 5, 2006 04:16 AM

Thanks, i had some similar but it doesn't work well when +X, +V or +C are pressed because the value of KeyCode is "Control", not "X", "V", or "C".
Nevertheless, when any other key is pressed, the value of keycode is correct.

Thanks,
Surti.


>Hi Surti,

To control the +V,+C keystroke in KeyDown event, you need to find the keystroke and set e.Handled = true to cancel the default behavior. Here is a code snippet to show this.

private void gridControl1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
Keys modifierKeys = Control.ModifierKeys;
Keys keyCode = e.KeyCode & Keys.KeyCode;
bool controlKeyDown = (e.Modifiers & Keys.Control) != Keys.None;
bool menuKeyDown = (e.Modifiers & Keys.Menu) != Keys.None;
switch (keyCode)
{
case Keys.V: // +V
if (controlKeyDown && !menuKeyDown)
{
Console.WriteLine("+V Pressed");
e.Handled = true;
}
break;
case Keys.C: // +C
if (controlKeyDown && !menuKeyDown)
{
Console.WriteLine("+C Pressed");
e.Handled = true;
}
break;
case Keys.X: // +X
if (controlKeyDown && !menuKeyDown)
{
Console.WriteLine("+X Pressed");
e.Handled = true;
}
break;
}
}
}

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On December 5, 2006 06:16 AM

Hi, the code you sendme doesn´t work well because when i press "CTRL" with one of these keys (X, V or C) value of keycode is "Control", not "X", "V" or "C". Do you know why???

Thanks,
Surti.

Administrator [Syncfusion]
Replied On December 5, 2006 06:32 AM

Hi Surti,

We tried to reproduce this in V4.x by just implement KeyDown event in a GridControl, but could not get this issue. Maybe I am not following the steps that you are doing. Attached sample working fine here. Can you post a small sample showing this problem or tell us how to see it in the Browser sample/Attached sample?

Here is a sample for implementing it.
GC_KeyDownevent.zip

If you can provide more information, we can try to suggest some solution.

Regards,
Haneef

Administrator [Syncfusion]
Replied On December 5, 2006 06:46 AM

Hi,

I have Essential Suite 1.5.1.1.
I have same code that you send me but when i press the combination of CTRL with one of these three keys, the value of keycode, in keydown event, is "Control".

Previosly i had configured following properties of GC,

GridControl1.WantTabKey = false
GridControl1.NumberedColHeaders = false

Thanks,
Surti

PD: Sorry for my english.

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.

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.

;