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. Image for the cookie policy date

ClipboardCanPaste is executed twice by the grid

Hi, I have a problem where ClipboardCanPaste is executed twice by the grid when i call Ctrl-V. In menus in the form i had edit menu where contains Cut, Copy, Paste operation where each shorcut are Ctrl-X, Ctrl-C and Ctrl-V. In each submenus i add code to send keys to the control, like this: SendKeys.Send("^(V)"); How can i solve this problem? thanks wirawan

5 Replies

IG I Gusti Ngurah Wirawan October 20, 2005 08:57 AM UTC

attaching a sample of code.

WindowsApplication21.zip


AD Administrator Syncfusion Team October 20, 2005 09:13 AM UTC

Here is sample that has a ctl+V Paste menu item that works on the grid and the ClipboardCanPaste is only hit once for me using version 3.3. http://www.syncfusion.com/Support/user/uploads/GDBG_CtlV_40c5bd3c.zip


IG I Gusti Ngurah Wirawan October 20, 2005 09:41 AM UTC

thanks for your quick response. the problem is i must do as same as when i click the paste submenus as i do Ctrl-V to others control, so i use this code "SendKeys.Send("^(V)");". and when i add that code in your solution it still raise ClipboardCanPaste executed twice. any other idea that u can share with me. regards wirawan


AD Administrator Syncfusion Team October 20, 2005 10:12 AM UTC

In the sample I sent, the event was only hit once, correct? You can put a check in your CanPaste handler to only do your code once. Here is a handler that I used in your sample to only display th emessage box once.
private void DataBoundGridModel_ClipboardCanPaste(object sender, Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs e)
{
	e.Handled = true;
	bool controlKeyDown = (Control.ModifierKeys & Keys.Control) != Keys.None;
	if(controlKeyDown)
	{
		MessageBox.Show("can paste called");
	}
}


IG I Gusti Ngurah Wirawan October 21, 2005 01:18 AM UTC

Thanks Clay, its working.

Loader.
Live Chat Icon For mobile
Up arrow icon