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
close icon

How to capture cell value changes after copy/paste

Hi,

I'm using gridControl 4.4.0.51, and I catch CurrentCellChanged event to do something when the value in a specific cell has been changed. However, if users copy some values and paste to several cells which include the cell i'm interested in, then the CurrentCellChanged event is not fired. I tried CellChanged event as well, but it didn't work either.

So, basically how can I capture a cell value change when use copies and pastes to the grid?

Thanks,

Frank
UBS, Mortgage IT


4 Replies

AD Administrator Syncfusion Team February 21, 2008 11:23 AM UTC

Hi Frank,

You can capture the value changed when user copies and pastes to the grid by using GridCutPasteEventArgs. The following code snippet shows how you can capture value changed.


bool b = true; // class level variable
private void gridControl1_ClipboardCut(object sender, Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs e)
{
if(this.b)
{
e.Handled = true;
this.b = !this.b;
Console.WriteLine("gridControl1_ClipboardCut");
}
}


Please refer the sample in the below link which illustrates the above.

http://websamples.syncfusion.com/samples/Tools.Windows/F71941/main.htm”

Let us know if this is not what you needed.

Regards,
Asem.




FR Frank February 21, 2008 05:07 PM UTC

Asem,

Thanks for your reply, but this approach doesn't solve my problem.

gridControl1_ClipboardPaste is raised BEFORE the values are set in the cells, which means I won't be able to read the value that user copy and paste to the cells from the event handler.

What I need is this: when user copy and paste some values from somewhere, let's say 10 values from an excel spreadsheet column to the grid, then 10 cells on the grid will be set with some values. If the fifth cell on this column is set to a certain value, say 888, then I need to do something about it.

Normally, if the user edits the cell directly, i can just handle the CurrentCellChanged event, but if the user copies and pastes, then how I can capture that?

Thanks,

Frank



AD Administrator Syncfusion Team February 25, 2008 06:18 AM UTC


Hi Frank,

If you want to read the value that user paste to the cells, you can use SaveCellInfo instead of ClipboardPaste.
SaveCellInfo is fired after the content of a cell is changed. You can use the SaveCellInfor as follows.


[C#]
void GridSaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
if( e.ColIndex > 0 && e.RowIndex > 0)
{
// Store data back to the datasource from the grid cell.
this._extData[e.RowIndex - 1, e.ColIndex - 1] = int.Parse(e.Style.CellValue.ToString());
e.Handled = true;
}
}


Kindly have a look at the sample in the below link which implements the above work around.

http://websamples.syncfusion.com/samples/Grid.Windows/F71914_A/main.htm


Please let me know if you have any queries.

Regards,
Asem.




FR Frank February 25, 2008 03:13 PM UTC

It works. Thanks.



Loader.
Live Chat Icon For mobile
Up arrow icon