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

Copy and Paste

Thread ID:





19633 Sep 30,2004 01:22 PM UTC Sep 30,2004 04:04 PM UTC WinForms 3
Tags: GridControl
Philip Bishop
Asked On September 30, 2004 01:22 PM UTC

Im attaching a sample that i wondered if you could help me with. I just found this problem today and I cant figure out whats going on with it. If you run the sample and click cell 1,1 and type in 999 and dont do anything else. After you type 999 and ur still in active edit mode hit ctrl-c. this takes u to the menu we have since we disabled ur context menu using ur code and then it does the copy and paste. The problem is that 999 is an invalid value for that cell. so it goes to the currentcellvalidating routine and gives u the proper error message. thats what it is suppose to do but then it crashes and im not sure why. if i remove the e.cancel from the currentcellvalidating it works fine, but if i just click on cell 1,1 again and type 999 again and then arrow off the cell then it wont reset the value like i need it too and will move off the cell leaving invalid data. thats what e.cancel is suppose to do. taking e.cancel out works fine if they try to copy and paste in active edit mode..i cant figure out whats going on. so what i cant figure out is what does leaving the grid have to do with the e.cancel causing it to blow up. Let me know if you have any questions. copypaste_5311.zip

Administrator [Syncfusion]
Replied On September 30, 2004 02:59 PM UTC

This code worked around the problem for me. An exception was being thrown in the validation which is being triigerred by your CurrentCell.EndEdit call, and this was being ignored by the code which was going ahead and sending the ctl+C key.
  Private Sub mnuEditCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditCopy.Click
        End Try
    End Sub

Philip Bishop
Replied On September 30, 2004 03:31 PM UTC

So what exactly is causing the exception?? I see how u have the return places that it will skip the sendkeys that i have in there. Why does that cause an excetpion??

Administrator [Syncfusion]
Replied On September 30, 2004 04:04 PM UTC

If you run your code in the debugger with it set to stop on exception, you will see where the exception is being generated. You setting e.Cancel in the validating event because the causes the currentcell.ConfirmChanges call to fail in the currentcell.EndEdit code. The grid throws an exception at this point to tell the caller of EndEdit that the process did not complete. Since you are calling EndEdit at this point, you would have to handle this exception. Here is the relevant code from our library. It is the ConfirmChanges if block that triggers the exception.
public void EndEdit()
	if (IsLocked || cellRenderer == null)
	if (isEditing)
		if (IsDroppedDown)
		if (IsModified)
			if (!this.ConfirmChanges())
				if (this.Exception != null)
					throw this.Exception;
					throw new Exception(ErrorMessage);
		isEditing = false;


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon