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.
Syncfusion Feedback

Errors During Paste of Range of Cells

Thread ID:

Created:

Updated:

Platform:

Replies:

25683 Mar 3,2005 06:05 PM UTC Mar 3,2005 08:02 PM UTC Windows Forms 3
loading
Tags: GridControl
Jeff Lancaster
Asked On March 3, 2005 06:05 PM UTC

When pasting a range of cells in my Data Bound Grid it is possible to run into an error on one of the cells, such as the error "Input string was not in the correct format". Currently when this happens the cells that were pasted in this operation up to this point will stay put, but any further cells in the range will not attempt to paste. Additionally, when this happens, the Model.ClipboardPasted event doesn''t get fired, an event in which I am doing some important post-paste operations. I would like to find a way to either cancel the entire paste operation when these errors are raised, or at least finish the operation for the remainder of the valid cells and ensure that the ClipboardPasted event fires upon completion. Any suggestions? Thanks, Jeff

Administrator [Syncfusion]
Replied On March 3, 2005 07:04 PM UTC

Try handling the PasteCelltext event. This is raised cell by cell as the text is being pasted. You can validate the text before grid tries to do the past on that cell. You have the option of canceling the single cell paste or cancelly the rest of the paste as well.

Jeff Lancaster
Replied On March 3, 2005 07:49 PM UTC

Thanks, Clay. Is there an easy way in this event to compare the text to the style and just cancel the cell paste if it won''t work? Or do I need to write my own set of validation rules for each column in the grid? I can certainly do this but I have a lot of columns so it will take quite a bit of code. If there''s a way to just "pre-try" the paste for each cell and catch the errors when they occur, that would be much simpler. Jeff

Administrator [Syncfusion]
Replied On March 3, 2005 08:02 PM UTC

You could try code like this. It actually handles setting the values in the paste.
private void Model_PasteCellText(object sender, GridPasteCellTextEventArgs e)
{
	try
	{
		this.gridDataBoundGrid1[e.RowIndex, e.ColIndex].Text = e.Text;
		e.Cancel = true; //cancel it as you did the paste
	}
	catch
	{
		//don''t show the message
		this.gridDataBoundGrid1.CurrentCell.ErrorMessage = "";
		e.Cancel = true; //as it cannot be done
		//e.Abort = true;//if you want to stop pasting rest of cells
	}
}

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

;